Class: Mutant::Integration::Rspec
- Inherits:
-
Mutant::Integration
- Object
- Mutant::Integration
- Mutant::Integration::Rspec
- Defined in:
- lib/mutant/integration/rspec.rb
Overview
Rspec integration
This looks so complicated, because rspec:
- Keeps its state global in RSpec.world and lots of other places
- There is no API to "just run a subset of examples", the examples
need to be selected in-place via mutating the
RSpec.filtered_examplesdata structure - Does not maintain a unique identification for an example,
aside the instances of
RSpec::Core::Exampleobjects itself. For that reason identifying examples by:- full description
- location Is NOT enough. It would not be unique. So we add an "example index" for unique reference.
Defined Under Namespace
Classes: Ordering
Constant Summary collapse
- ALL_EXPRESSION =
Expression::Namespace::Recursive.new(scope_name: nil)
- EXPRESSION_CANDIDATE =
/\A([^ ]+)(?: )?/- EXIT_SUCCESS =
0- DEFAULT_CLI_OPTIONS =
%w[--fail-fast spec].freeze
- TEST_ID_FORMAT =
'rspec:%<index>d:%<location>s/%<description>s'
Instance Method Summary collapse
-
#all_tests ⇒ Enumerable<Test>
All tests.
-
#available_tests ⇒ Enumerable<Test>
Available tests.
-
#call(tests) ⇒ Result::Test
Run a collection of tests, likeliest killer first.
-
#freeze ⇒ Object
Ordering.
-
#initialize ⇒ undefined
constructor
Initialize rspec integration.
-
#setup ⇒ self
Setup rspec integration.
Constructor Details
Instance Method Details
#all_tests ⇒ Enumerable<Test>
All tests
137 |
# File 'lib/mutant/integration/rspec.rb', line 137 def all_tests = all_tests_index.keys |
#available_tests ⇒ Enumerable<Test>
Available tests
143 |
# File 'lib/mutant/integration/rspec.rb', line 143 def available_tests = all_tests_index.select { |_test, example| example..fetch(:mutant, true) }.keys |
#call(tests) ⇒ Result::Test
Run a collection of tests, likeliest killer first
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/mutant/integration/rspec.rb', line 112 def call(tests) examples = tests.map(&all_tests_index) install_ordering reset_examples @ordering.call(examples) setup_examples(examples) @runner.configuration.start_time = world.time.now - @setup_elapsed start = timer.now passed = @runner.run_specs(@rspec_world.ordered_example_groups).equal?(EXIT_SUCCESS) @runner.configuration.reset_reporter Result::Test.new( job_index: nil, output: LogCapture::String.new(content: ''), passed:, runtime: timer.now - start ) end |
#freeze ⇒ Object
Ordering
76 |
# File 'lib/mutant/integration/rspec.rb', line 76 def freeze = tap { super if @setup_elapsed } |
#setup ⇒ self
Setup rspec integration
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/mutant/integration/rspec.rb', line 91 def setup @setup_elapsed = timer.elapsed do @runner.setup(world.stderr, world.stdout) fail 'RSpec setup failure' if rspec_setup_failure? example_group_map end @runner.configuration.force(color_mode: :on) @runner.configuration.reporter reset_examples freeze end |