Class: RSpecQueue::Formatter
- Inherits:
-
RSpec::Core::Formatters::ProgressFormatter
- Object
- RSpec::Core::Formatters::ProgressFormatter
- RSpecQueue::Formatter
- Defined in:
- lib/rspec_queue/formatter.rb
Instance Method Summary collapse
- #dump_failures(_summary) ⇒ Object
- #dump_pending(_notification) ⇒ Object
- #dump_summary(summary) ⇒ Object
- #example_failed(failure) ⇒ Object
- #example_pending(pending) ⇒ Object
-
#initialize(output) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(output) ⇒ Formatter
Returns a new instance of Formatter.
9 10 11 12 13 |
# File 'lib/rspec_queue/formatter.rb', line 9 def initialize(output) super @output = output @failed_examples = [] end |
Instance Method Details
#dump_failures(_summary) ⇒ Object
46 47 48 |
# File 'lib/rspec_queue/formatter.rb', line 46 def dump_failures(_summary) # no-op because we already printed failures once end |
#dump_pending(_notification) ⇒ Object
50 51 52 |
# File 'lib/rspec_queue/formatter.rb', line 50 def dump_pending(_notification) # no-op because we already printed failures once end |
#dump_summary(summary) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rspec_queue/formatter.rb', line 25 def dump_summary(summary) colorizer = RSpec::Core::Formatters::ConsoleCodes results_output = [ "Finished in #{summary.formatted_duration}", "(files took #{summary.formatted_load_time} to load)", "#{summary.colorized_totals_line}" ].join("\n") slowest_examples = summary.examples.sort_by { |e| e[:run_time] }.reverse[0..4] slowest_example_output = formatted_slowest_examples(slowest_examples, summary.duration, colorizer) summary_output = [ results_output, "Top 5 slowest examples:", slowest_example_output ].join("\n") @output.puts summary_output end |
#example_failed(failure) ⇒ Object
15 16 17 18 |
# File 'lib/rspec_queue/formatter.rb', line 15 def example_failed(failure) @failed_examples << failure.example @output.puts failure.fully_formatted(@failed_examples.size) end |
#example_pending(pending) ⇒ Object
20 21 22 23 |
# File 'lib/rspec_queue/formatter.rb', line 20 def example_pending(pending) @output.puts "\nPending: #{RSpec::Core::Formatters::ConsoleCodes.wrap(pending.example.[:execution_result]., :yellow)}" @output.puts " #{RSpec::Core::Formatters::ConsoleCodes.wrap(pending.example.[:location], :cyan)}\n" end |