Class: TurboTests::Reporter
- Inherits:
-
Object
- Object
- TurboTests::Reporter
- Defined in:
- lib/turbo_tests/reporter.rb
Instance Attribute Summary collapse
-
#failed_examples ⇒ Object
readonly
Returns the value of attribute failed_examples.
-
#formatters ⇒ Object
readonly
Returns the value of attribute formatters.
-
#pending_examples ⇒ Object
readonly
Returns the value of attribute pending_examples.
Class Method Summary collapse
Instance Method Summary collapse
- #add(name, outputs) ⇒ Object
- #add_formatter(formatter) ⇒ Object
- #error_outside_of_examples ⇒ Object
- #example_failed(example) ⇒ Object
- #example_passed(example) ⇒ Object
- #example_pending(example) ⇒ Object
- #finish ⇒ Object
-
#initialize(start_time:, max_timings_count:) ⇒ Reporter
constructor
A new instance of Reporter.
- #message(message) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(start_time:, max_timings_count:) ⇒ Reporter
Returns a new instance of Reporter.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/turbo_tests/reporter.rb', line 23 def initialize(start_time:, max_timings_count:) @formatters = [] @pending_examples = [] @failed_examples = [] @all_examples = [] @start_time = start_time @messages = [] @errors_outside_of_examples_count = 0 @timings = [] @max_timings_count = max_timings_count end |
Instance Attribute Details
#failed_examples ⇒ Object (readonly)
Returns the value of attribute failed_examples.
20 21 22 |
# File 'lib/turbo_tests/reporter.rb', line 20 def failed_examples @failed_examples end |
#formatters ⇒ Object (readonly)
Returns the value of attribute formatters.
21 22 23 |
# File 'lib/turbo_tests/reporter.rb', line 21 def formatters @formatters end |
#pending_examples ⇒ Object (readonly)
Returns the value of attribute pending_examples.
19 20 21 |
# File 'lib/turbo_tests/reporter.rb', line 19 def pending_examples @pending_examples end |
Class Method Details
.from_config(formatter_config, start_time, max_timings_count: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/turbo_tests/reporter.rb', line 5 def self.from_config(formatter_config, start_time, max_timings_count: nil) reporter = new(start_time:, max_timings_count:) formatter_config.each do |config| name, outputs = config.values_at(:name, :outputs) outputs.map! { |filename| filename == "-" ? STDOUT : File.open(filename, "w") } reporter.add(name, outputs) end reporter end |
Instance Method Details
#add(name, outputs) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/turbo_tests/reporter.rb', line 35 def add(name, outputs) outputs.each do |output| formatter_class = case name when "p", "progress" TurboTests::ProgressFormatter when "d", "documentation" TurboTests::DocumentationFormatter else Kernel.const_get(name) end add_formatter(formatter_class.new(output)) end end |
#add_formatter(formatter) ⇒ Object
120 121 122 |
# File 'lib/turbo_tests/reporter.rb', line 120 def add_formatter(formatter) @formatters << formatter end |
#error_outside_of_examples ⇒ Object
83 84 85 |
# File 'lib/turbo_tests/reporter.rb', line 83 def error_outside_of_examples @errors_outside_of_examples_count += 1 end |
#example_failed(example) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/turbo_tests/reporter.rb', line 70 def example_failed(example) delegate_to_formatters(:example_failed, example.notification) @all_examples << example @failed_examples << example log_timing(example) end |
#example_passed(example) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/turbo_tests/reporter.rb', line 55 def example_passed(example) delegate_to_formatters(:example_passed, example.notification) @all_examples << example log_timing(example) end |
#example_pending(example) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/turbo_tests/reporter.rb', line 62 def example_pending(example) delegate_to_formatters(:example_pending, example.notification) @all_examples << example @pending_examples << example log_timing(example) end |
#finish ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/turbo_tests/reporter.rb', line 87 def finish end_time = Time.now delegate_to_formatters(:stop, RSpec::Core::Notifications::ExamplesNotification.new(self)) delegate_to_formatters(:start_dump, RSpec::Core::Notifications::NullNotification) delegate_to_formatters( :dump_pending, RSpec::Core::Notifications::ExamplesNotification.new(self), ) delegate_to_formatters( :dump_failures, RSpec::Core::Notifications::ExamplesNotification.new(self), ) delegate_to_formatters( :dump_summary, RSpec::Core::Notifications::SummaryNotification.new( end_time - @start_time, @all_examples, @failed_examples, @pending_examples, 0, @errors_outside_of_examples_count, ), @timings, ) delegate_to_formatters(:close, RSpec::Core::Notifications::NullNotification) end |
#message(message) ⇒ Object
78 79 80 81 |
# File 'lib/turbo_tests/reporter.rb', line 78 def () delegate_to_formatters(:message, RSpec::Core::Notifications::MessageNotification.new()) @messages << end |
#start ⇒ Object
51 52 53 |
# File 'lib/turbo_tests/reporter.rb', line 51 def start delegate_to_formatters(:start, RSpec::Core::Notifications::StartNotification.new) end |