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.



22
23
24
25
26
27
28
29
30
# File 'lib/fuubar.rb', line 22

def initialize(*args)
  super

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

Instance Attribute Details

#failed_countObject

Returns the value of attribute failed_count.



17
18
19
# File 'lib/fuubar.rb', line 17

def failed_count
  @failed_count
end

#passed_countObject

Returns the value of attribute passed_count.



17
18
19
# File 'lib/fuubar.rb', line 17

def passed_count
  @passed_count
end

#pending_countObject

Returns the value of attribute pending_count.



17
18
19
# File 'lib/fuubar.rb', line 17

def pending_count
  @pending_count
end

#progressObject

Returns the value of attribute progress.



17
18
19
# File 'lib/fuubar.rb', line 17

def progress
  @progress
end

Instance Method Details

#dump_failures(notification) ⇒ Object



81
82
83
84
85
86
# File 'lib/fuubar.rb', line 81

def dump_failures(notification)
  #
  # 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(notification) ⇒ Object



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

def example_failed(notification)
  self.failed_count += 1

  progress.clear

  output.puts notification.fully_formatted(failed_count)
  output.puts

  increment
end

#example_passed(notification) ⇒ Object



50
51
52
53
54
# File 'lib/fuubar.rb', line 50

def example_passed(notification)
  self.passed_count += 1

  increment
end

#example_pending(notification) ⇒ Object



56
57
58
59
60
# File 'lib/fuubar.rb', line 56

def example_pending(notification)
  self.pending_count += 1

  increment
end

#message(notification) ⇒ Object



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

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

#start(notification) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fuubar.rb', line 32

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

  self.progress      = ProgressBar.create(progress_bar_options)
  self.passed_count  = 0
  self.pending_count = 0
  self.failed_count  = 0

  super

  with_current_color { progress.start }
end