Class: Fuubar

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/fuubar.rb

Constant Summary collapse

DEFAULT_PROGRESS_BAR_OPTIONS =
{ :format => ' %c/%C |%w>%i| %e ' }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Fuubar

Returns a new instance of Fuubar.



12
13
14
15
16
17
18
19
20
# File 'lib/fuubar.rb', line 12

def initialize(*args)
  super

  self.progress = ProgressBar.create(DEFAULT_PROGRESS_BAR_OPTIONS.
                                      merge(:throttle_rate  => continuous_integration? ? 1.0 : nil).
                                      merge(:total          => example_count,
                                            :output         => output,
                                            :autostart      => false))
end

Instance Attribute Details

#progressObject

Returns the value of attribute progress.



10
11
12
# File 'lib/fuubar.rb', line 10

def progress
  @progress
end

Instance Method Details

#dump_failuresObject



72
73
74
75
76
77
# File 'lib/fuubar.rb', line 72

def dump_failures
  #
  # We output each failure as it happens so we don't need to output them en
  # masse at the end of the run.
  #
end

#example_failed(example) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fuubar.rb', line 51

def example_failed(example)
  super

  progress.clear

  dump_failure    example, failed_examples.size - 1
  dump_backtrace  example

  output.puts

  increment
end

#example_passed(example) ⇒ Object



39
40
41
42
43
# File 'lib/fuubar.rb', line 39

def example_passed(example)
  super

  increment
end

#example_pending(example) ⇒ Object



45
46
47
48
49
# File 'lib/fuubar.rb', line 45

def example_pending(example)
  super

  increment
end

#message(string) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/fuubar.rb', line 64

def message(string)
  if progress.respond_to? :log
    progress.log(string)
  else
    super
  end
end

#start(example_count) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fuubar.rb', line 22

def start(example_count)
  progress_bar_options =  DEFAULT_PROGRESS_BAR_OPTIONS.
                            merge(:throttle_rate  => continuous_integration? ? 1.0 : nil).
                            merge(configuration.fuubar_progress_bar_options).
                            merge(:total          => example_count,
                                  :output         => output,
                                  :autostart      => false)

  self.progress = ProgressBar.create(progress_bar_options)

  super

  progress.total = example_count

  with_current_color { progress.start }
end