Class: Fuubar
- Inherits:
-
RSpec::Core::Formatters::BaseTextFormatter
- Object
- RSpec::Core::Formatters::BaseTextFormatter
- Fuubar
- Defined in:
- lib/fuubar.rb
Instance Method Summary collapse
- #colors ⇒ Object
- #dump_failures ⇒ Object
- #example_failed(example) ⇒ Object
- #example_passed(example) ⇒ Object
- #example_pending(example) ⇒ Object
- #increment ⇒ Object
- #instafail ⇒ Object
- #message(string) ⇒ Object
- #start(example_count) ⇒ Object
- #state ⇒ Object
- #with_color ⇒ Object
Instance Method Details
#colors ⇒ Object
66 67 68 |
# File 'lib/fuubar.rb', line 66 def colors { :red => 31, :green => 32, :yellow => 33 } end |
#dump_failures ⇒ Object
40 41 42 |
# File 'lib/fuubar.rb', line 40 def dump_failures # don't! end |
#example_failed(example) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fuubar.rb', line 29 def example_failed(example) super @state = :red output.print "\e[K" instafail.example_failed(example) output.puts increment end |
#example_passed(example) ⇒ Object
18 19 20 21 |
# File 'lib/fuubar.rb', line 18 def example_passed(example) super increment end |
#example_pending(example) ⇒ Object
23 24 25 26 27 |
# File 'lib/fuubar.rb', line 23 def example_pending(example) super @state = :yellow unless @state == :red increment end |
#increment ⇒ Object
12 13 14 15 16 |
# File 'lib/fuubar.rb', line 12 def increment with_color do @progress_bar.increment end end |
#instafail ⇒ Object
52 53 54 |
# File 'lib/fuubar.rb', line 52 def instafail @instafail ||= RSpec::Instafail.new(output) end |
#message(string) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/fuubar.rb', line 44 def (string) if @progress_bar.respond_to? :log @progress_bar.log(string) else super end end |
#start(example_count) ⇒ Object
7 8 9 10 |
# File 'lib/fuubar.rb', line 7 def start(example_count) super @progress_bar = ProgressBar.create(:format => ' %c/%C |%w>%i| %e ', :total => example_count, :output => output) end |
#state ⇒ Object
62 63 64 |
# File 'lib/fuubar.rb', line 62 def state @state ||= :green end |
#with_color ⇒ Object
56 57 58 59 60 |
# File 'lib/fuubar.rb', line 56 def with_color output.print "\e[#{colors[state]}m" if color_enabled? yield output.print "\e[0m" if color_enabled? end |