Class: RspecFlaky::Listener
- Inherits:
-
Object
- Object
- RspecFlaky::Listener
- Defined in:
- lib/rspec_flaky/listener.rb
Instance Attribute Summary collapse
-
#flaky_examples ⇒ Object
readonly
-
suite_flaky_examples: contains all the currently tracked flacky example for the whole RSpec suite - flaky_examples: contains the examples detected as flaky during the current RSpec run.
-
-
#suite_flaky_examples ⇒ Object
readonly
-
suite_flaky_examples: contains all the currently tracked flacky example for the whole RSpec suite - flaky_examples: contains the examples detected as flaky during the current RSpec run.
-
Instance Method Summary collapse
-
#dump_summary(_) ⇒ Object
rubocop:disable Gitlab/RailsLogger.
- #example_passed(notification) ⇒ Object
-
#initialize(suite_flaky_examples_json = nil) ⇒ Listener
constructor
A new instance of Listener.
Constructor Details
#initialize(suite_flaky_examples_json = nil) ⇒ Listener
Returns a new instance of Listener.
19 20 21 22 |
# File 'lib/rspec_flaky/listener.rb', line 19 def initialize(suite_flaky_examples_json = nil) @flaky_examples = RspecFlaky::FlakyExamplesCollection.new @suite_flaky_examples = init_suite_flaky_examples(suite_flaky_examples_json) end |
Instance Attribute Details
#flaky_examples ⇒ Object (readonly)
-
suite_flaky_examples: contains all the currently tracked flacky example for the whole RSpec suite
-
flaky_examples: contains the examples detected as flaky during the current RSpec run
17 18 19 |
# File 'lib/rspec_flaky/listener.rb', line 17 def flaky_examples @flaky_examples end |
#suite_flaky_examples ⇒ Object (readonly)
-
suite_flaky_examples: contains all the currently tracked flacky example for the whole RSpec suite
-
flaky_examples: contains the examples detected as flaky during the current RSpec run
17 18 19 |
# File 'lib/rspec_flaky/listener.rb', line 17 def suite_flaky_examples @suite_flaky_examples end |
Instance Method Details
#dump_summary(_) ⇒ Object
rubocop:disable Gitlab/RailsLogger
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rspec_flaky/listener.rb', line 36 def dump_summary(_) RspecFlaky::Report.new(flaky_examples).write(RspecFlaky::Config.flaky_examples_report_path) # write_report_file(flaky_examples, RspecFlaky::Config.flaky_examples_report_path) new_flaky_examples = flaky_examples - suite_flaky_examples if new_flaky_examples.any? Rails.logger.warn "\nNew flaky examples detected:\n" Rails.logger.warn Gitlab::Json.pretty_generate(new_flaky_examples.to_h) RspecFlaky::Report.new(new_flaky_examples).write(RspecFlaky::Config.new_flaky_examples_report_path) # write_report_file(new_flaky_examples, RspecFlaky::Config.new_flaky_examples_report_path) end end |
#example_passed(notification) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rspec_flaky/listener.rb', line 24 def example_passed(notification) current_example = RspecFlaky::Example.new(notification.example) return unless current_example.attempts > 1 flaky_example = suite_flaky_examples.fetch(current_example.uid) { RspecFlaky::FlakyExample.new(current_example) } flaky_example.update_flakiness!(last_attempts_count: current_example.attempts) flaky_examples[current_example.uid] = flaky_example end |