Class: Fuubar
- Inherits:
-
Spec::Runner::Formatter::BaseTextFormatter
- Object
- Spec::Runner::Formatter::BaseTextFormatter
- Fuubar
- Defined in:
- lib/fuubar.rb
Constant Summary collapse
- COLORS =
{ :green => "\e[32m", :yellow => "\e[33m", :red => "\e[31m" }
Instance Attribute Summary collapse
-
#example_count ⇒ Object
readonly
Returns the value of attribute example_count.
-
#finished_count ⇒ Object
readonly
Returns the value of attribute finished_count.
Instance Method Summary collapse
- #dump_failures ⇒ Object
- #example_failed(example, counter, message) ⇒ Object
- #example_passed(example) ⇒ Object
- #example_pending(example, message) ⇒ Object
- #increment ⇒ Object
- #instafail ⇒ Object
- #start(example_count) ⇒ Object
- #start_dump ⇒ Object
- #state ⇒ Object
- #with_color ⇒ Object
Instance Attribute Details
#example_count ⇒ Object (readonly)
Returns the value of attribute example_count.
7 8 9 |
# File 'lib/fuubar.rb', line 7 def example_count @example_count end |
#finished_count ⇒ Object (readonly)
Returns the value of attribute finished_count.
7 8 9 |
# File 'lib/fuubar.rb', line 7 def finished_count @finished_count end |
Instance Method Details
#dump_failures ⇒ Object
51 52 53 |
# File 'lib/fuubar.rb', line 51 def dump_failures # don't! end |
#example_failed(example, counter, message) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fuubar.rb', line 36 def example_failed(example, counter, ) super @state = :red output.print "\e[K" instafail.example_failed(example, counter, ) output.puts increment end |
#example_passed(example) ⇒ Object
25 26 27 28 |
# File 'lib/fuubar.rb', line 25 def example_passed(example) super increment end |
#example_pending(example, message) ⇒ Object
30 31 32 33 34 |
# File 'lib/fuubar.rb', line 30 def example_pending(example, ) super @state = :yellow unless @state == :red increment end |
#increment ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/fuubar.rb', line 17 def increment with_color do @finished_count += 1 @progress_bar.instance_variable_set("@title", " #{finished_count}/#{example_count}") @progress_bar.inc end end |
#instafail ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/fuubar.rb', line 55 def instafail @instafail ||= RSpec::Instafail.new(@options, output) #since instafail won't be able to get the current example_group it must be #updated every time @instafail.example_group_started(example_group) @instafail end |
#start(example_count) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/fuubar.rb', line 10 def start(example_count) @example_count = example_count @finished_count = 0 @progress_bar = ProgressBar.new(" #{example_count} examples", example_count, output) @progress_bar. = '=' end |
#start_dump ⇒ Object
47 48 49 |
# File 'lib/fuubar.rb', line 47 def start_dump with_color { @progress_bar.finish } end |
#state ⇒ Object
69 70 71 |
# File 'lib/fuubar.rb', line 69 def state @state ||= :green end |
#with_color ⇒ Object
63 64 65 66 67 |
# File 'lib/fuubar.rb', line 63 def with_color output.print COLORS[state] if colour? yield output.print "\e[0m" end |