Module: KnapsackPro::Extensions::RSpecExtension::Runner
- Defined in:
- lib/knapsack_pro/extensions/rspec_extension.rb
Instance Method Summary collapse
-
#knapsack__deprecated_run_all_when_everything_filtered_enabled? ⇒ Boolean
must be called after ‘Runner#knapsack__setup` that loads the `spec_helper.rb` configuration.
- #knapsack__error_exit_code ⇒ Object
- #knapsack__exit_early ⇒ Object
- #knapsack__load_spec_files_batch(test_file_paths) ⇒ Object
- #knapsack__persist_example_statuses ⇒ Object
- #knapsack__rspec_is_quitting? ⇒ Boolean
- #knapsack__run_specs(queue_runner) ⇒ Fixnum
- #knapsack__seed ⇒ Object
- #knapsack__setup(stream_error = $stderr, stream_out = $stdout) ⇒ Object
- #knapsack__wants_to_quit? ⇒ Boolean
Instance Method Details
#knapsack__deprecated_run_all_when_everything_filtered_enabled? ⇒ Boolean
must be called after ‘Runner#knapsack__setup` that loads the `spec_helper.rb` configuration
56 57 58 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 56 def knapsack__deprecated_run_all_when_everything_filtered_enabled? configuration.respond_to?(:run_all_when_everything_filtered) && !!configuration.run_all_when_everything_filtered end |
#knapsack__error_exit_code ⇒ Object
51 52 53 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 51 def knapsack__error_exit_code configuration.error_exit_code # nil unless `--error-exit-code` is specified end |
#knapsack__exit_early ⇒ Object
45 46 47 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 45 def knapsack__exit_early _exit_status = configuration.reporter.exit_early(exit_code) end |
#knapsack__load_spec_files_batch(test_file_paths) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 66 def knapsack__load_spec_files_batch(test_file_paths) world.reset # Reset filters, but do not reset `configuration.static_config_filter_manager` to preserve the --tag option filter_manager = RSpec::Core::FilterManager.new .configure_filter_manager(filter_manager) configuration.filter_manager = filter_manager configuration.knapsack__load_spec_files(test_file_paths) end |
#knapsack__persist_example_statuses ⇒ Object
118 119 120 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 118 def knapsack__persist_example_statuses persist_example_statuses end |
#knapsack__rspec_is_quitting? ⇒ Boolean
41 42 43 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 41 def knapsack__rspec_is_quitting? world.respond_to?(:rspec_is_quitting) && world.rspec_is_quitting end |
#knapsack__run_specs(queue_runner) ⇒ Fixnum
Ignore ‘configuration.fail_if_no_examples` in Queue Mode:
* a late CI node, started after all tests were executed by other nodes, is expected to receive an empty batch
* a batch could contain tests with no examples (e.g. commented out)
85 86 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 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 85 def knapsack__run_specs(queue_runner) # Based on: # https://github.com/rspec/rspec-core/blob/f8c8880dabd8f0544a6f91d8d4c857c1bd8df903/lib/rspec/core/world.rb#L53 ordering_strategy = configuration.ordering_registry.fetch(:global) node_examples_passed = true configuration.reporter.report(_expected_example_count = 0) do |reporter| configuration.with_suite_hooks do queue_runner.with_batch do |test_file_paths| knapsack__load_spec_files_batch(test_file_paths) examples_passed = ordering_strategy.order(world.example_groups).map do |example_group| queue_runner.handle_signal! example_group.run(reporter) end.all? node_examples_passed = false unless examples_passed knapsack__persist_example_statuses if reporter.fail_fast_limit_met? queue_runner.log_fail_fast_limit_met break end end end exit_code(node_examples_passed) end end |
#knapsack__seed ⇒ Object
60 61 62 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 60 def knapsack__seed Seed.new(configuration.seed.to_s, configuration.seed_used?) end |
#knapsack__setup(stream_error = $stderr, stream_out = $stdout) ⇒ Object
‘@configuration.load_spec_files` is not called because we load tests in batches with `knapsack__load_spec_files_batch` later on.
31 32 33 34 35 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 31 def knapsack__setup(stream_error = $stderr, stream_out = $stdout) configure(stream_error, stream_out) ensure world.knapsack__announce_filters end |
#knapsack__wants_to_quit? ⇒ Boolean
37 38 39 |
# File 'lib/knapsack_pro/extensions/rspec_extension.rb', line 37 def knapsack__wants_to_quit? world.wants_to_quit end |