Class: RSpec::Core::Formatters::BaseBisectFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/base_bisect_formatter.rb

Overview

Contains common logic for formatters used by ‘–bisect` to communicate results back to the bisect runner.

Subclasses must define a ‘notify_results(all_example_ids, failed_example_ids)` method.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_failures) ⇒ BaseBisectFormatter

Returns a new instance of BaseBisectFormatter.



17
18
19
20
21
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/base_bisect_formatter.rb', line 17

def initialize(expected_failures)
  @all_example_ids = []
  @failed_example_ids = []
  @remaining_failures = expected_failures
end

Class Method Details

.inherited(formatter) ⇒ Object



13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/base_bisect_formatter.rb', line 13

def self.inherited(formatter)
  Formatters.register formatter, :start_dump, :example_failed, :example_finished
end

Instance Method Details

#example_failed(notification) ⇒ Object



23
24
25
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/base_bisect_formatter.rb', line 23

def example_failed(notification)
  @failed_example_ids << notification.example.id
end

#example_finished(notification) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/base_bisect_formatter.rb', line 27

def example_finished(notification)
  @all_example_ids << notification.example.id
  return unless @remaining_failures.include?(notification.example.id)
  @remaining_failures.delete(notification.example.id)

  status = notification.example.execution_result.status
  return if status == :failed && !@remaining_failures.empty?
  RSpec.world.wants_to_quit = true
end

#start_dump(_notification) ⇒ Object



37
38
39
40
41
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/base_bisect_formatter.rb', line 37

def start_dump(_notification)
  # `notify_results` is defined in the subclass
  notify_results(Bisect::ExampleSetDescriptor.new(
    @all_example_ids, @failed_example_ids))
end