Class: FastCI::RspecFormatter
- Inherits:
-
Object
- Object
- FastCI::RspecFormatter
- Defined in:
- lib/fast_ci/rspec_formatter.rb
Instance Attribute Summary collapse
-
#current_test_key ⇒ Object
Returns the value of attribute current_test_key.
Instance Method Summary collapse
- #dump_and_reset ⇒ Object
- #example_finished(notification) ⇒ Object
-
#initialize ⇒ RspecFormatter
constructor
A new instance of RspecFormatter.
- #passed? ⇒ Boolean
Constructor Details
#initialize ⇒ RspecFormatter
7 8 9 10 |
# File 'lib/fast_ci/rspec_formatter.rb', line 7 def initialize @output = {} @is_failed = false end |
Instance Attribute Details
#current_test_key ⇒ Object
Returns the value of attribute current_test_key.
5 6 7 |
# File 'lib/fast_ci/rspec_formatter.rb', line 5 def current_test_key @current_test_key end |
Instance Method Details
#dump_and_reset ⇒ Object
51 52 53 54 55 |
# File 'lib/fast_ci/rspec_formatter.rb', line 51 def dump_and_reset output = @output @output = {} output end |
#example_finished(notification) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fast_ci/rspec_formatter.rb', line 20 def example_finished(notification) example = notification.example = example. *example_group_ids, example_id = [:scoped_id].split(":") file_output = @output[current_test_key] ||= {} example_group = example_group_ids.reduce(file_output) do |output, scope_id| output[scope_id] ||= {} output[scope_id] end example_group[example_id] = { run_time: example.execution_result.run_time, status: example.execution_result.status } if example.execution_result.status == :failed @is_failed = true example_group[example_id][:fully_formatted] = notification.fully_formatted(0, ::RSpec::Core::Formatters::ConsoleCodes) elsif [:retry_attempts] && [:retry_attempts] > 0 example_group[example_id][:retry_attempts] = [:retry_attempts] example_group[example_id][:fully_formatted] = example.set_exception [:retry_exceptions].first.to_s end example_group[example_id] end |
#passed? ⇒ Boolean
12 13 14 |
# File 'lib/fast_ci/rspec_formatter.rb', line 12 def passed? !@is_failed end |