Class: Uninhibited::Formatter
- Inherits:
-
RSpec::Core::Formatters::DocumentationFormatter
- Object
- RSpec::Core::Formatters::DocumentationFormatter
- Uninhibited::Formatter
- Defined in:
- lib/uninhibited/formatter.rb
Overview
Custom formatter for displaying the results of a feature.
Instance Attribute Summary collapse
-
#skipped_count ⇒ Object
the number of skipped examples.
-
#skipped_examples ⇒ Object
readonly
the skipped examples.
Instance Method Summary collapse
-
#colorise_summary(summary) ⇒ String
Stubbed method to return the summary as provided, since the summary will already be colorized.
-
#cyan(text) ⇒ String
Generate a string to output to the terminal with cyan coloration.
-
#example_pending(example) ⇒ Object
Adds the pending example to skipped examples array if it was skipped, otherwise it delegates to super.
-
#initialize(output) ⇒ Formatter
constructor
Builds a new formatter for outputting Uninhibited features.
-
#summary_line(example_count, failure_count, pending_count) ⇒ String
Generates a colorized summary line based on the supplied arguments.
Constructor Details
#initialize(output) ⇒ Formatter
Builds a new formatter for outputting Uninhibited features.
18 19 20 21 22 |
# File 'lib/uninhibited/formatter.rb', line 18 def initialize(output) super @skipped_examples = [] @skipped_count = 0 end |
Instance Attribute Details
#skipped_count ⇒ Object
the number of skipped examples
8 9 10 |
# File 'lib/uninhibited/formatter.rb', line 8 def skipped_count @skipped_count end |
#skipped_examples ⇒ Object (readonly)
the skipped examples
12 13 14 |
# File 'lib/uninhibited/formatter.rb', line 12 def skipped_examples @skipped_examples end |
Instance Method Details
#colorise_summary(summary) ⇒ String
Stubbed method to return the summary as provided, since the summary will already be colorized.
44 45 46 |
# File 'lib/uninhibited/formatter.rb', line 44 def colorise_summary(summary) summary end |
#cyan(text) ⇒ String
Generate a string to output to the terminal with cyan coloration
82 83 84 |
# File 'lib/uninhibited/formatter.rb', line 82 def cyan(text) color(text, "\e[36m") end |
#example_pending(example) ⇒ Object
Adds the pending example to skipped examples array if it was skipped, otherwise it delegates to super.
28 29 30 31 32 33 34 35 36 |
# File 'lib/uninhibited/formatter.rb', line 28 def example_pending(example) if example_group.[:feature] && example.[:skipped] @skipped_examples << pending_examples.delete(example) @skipped_count += 1 output.puts cyan("#{current_indentation}#{example.description}") else super end end |
#summary_line(example_count, failure_count, pending_count) ⇒ String
Generates a colorized summary line based on the supplied arguments.
formatter.summary_line(1, 0, 0)
# => 1 example (0 failures)
formatter.summary_line(2, 1, 1)
# => 2 examples (1 failure, 1 pending)
formatter.skipped_count += 1
formatter.summary_line(2, 0, 0)
# => 2 examples (1 failure, 1 skipped)
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/uninhibited/formatter.rb', line 67 def summary_line(example_count, failure_count, pending_count) pending_count -= skipped_count summary = pluralize(example_count, "example") summary << " (" summary << red(pluralize(failure_count, "failure")) summary << ", " << yellow("#{pending_count} pending") if pending_count > 0 summary << ", " << cyan("#{skipped_count} skipped") if skipped_count > 0 summary << ")" summary end |