From 322ae4b86421f5a16c9817210873d67f0f4282bf Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Tue, 5 Jan 2021 21:24:49 +0300 Subject: [PATCH] Remove `run_all_when_everything_filtered` configuration option --- Changelog.md | 1 + features/.nav | 1 - .../run_all_when_everything_filtered.feature | 82 ------------------- lib/rspec/core/bisect/fork_runner.rb | 6 -- lib/rspec/core/configuration.rb | 7 -- lib/rspec/core/world.rb | 6 -- spec/integration/bisect_runners_spec.rb | 21 ----- spec/rspec/core/configuration_spec.rb | 11 --- spec/rspec/core/world_spec.rb | 23 ------ 9 files changed, 1 insertion(+), 157 deletions(-) delete mode 100644 features/configuration/run_all_when_everything_filtered.feature diff --git a/Changelog.md b/Changelog.md index e403599e4c..5a17cfa747 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ Breaking Changes: * Extract `should` syntax (including the non-monkey-patching one liner). (Phil Pirozhkov, #2803) * Remove globally-exposed DSL (example and shared group methods in the root scope and on Module). (Phil Pirozhkov, #2803) +* Remove `run_all_when_everything_filtered` configuration option. (Phil Pirozhkov, #2845) Enhancements: diff --git a/features/.nav b/features/.nav index d6320e624c..60e2d8a5aa 100644 --- a/features/.nav +++ b/features/.nav @@ -38,7 +38,6 @@ - exclusion_filters.feature - if_and_unless.feature - filter_run_when_matching.feature - - run_all_when_everything_filtered.feature - configuration: - read_options_from_file.feature - color.feature diff --git a/features/configuration/run_all_when_everything_filtered.feature b/features/configuration/run_all_when_everything_filtered.feature deleted file mode 100644 index 5633bbebfe..0000000000 --- a/features/configuration/run_all_when_everything_filtered.feature +++ /dev/null @@ -1,82 +0,0 @@ -Feature: run all when everything filtered - - Note: this feature has been superseded by - [filter_run_when_matching](../filtering/filter-run-when-matching) and will be - removed in a future version of RSpec. - - Use the `run_all_when_everything_filtered` option to tell RSpec to run all the - specs in the case where you try to run a filtered list of specs but no specs - match that filter. This works well when paired with an inclusion filter like - `:focus => true`, as it will run all the examples when none match the - inclusion filter. - - ```ruby - RSpec.configure { |c| c.run_all_when_everything_filtered = true } - ``` - - Background: - Given a file named "spec/spec_helper.rb" with: - """ruby - RSpec.configure {|c| c.run_all_when_everything_filtered = true} - """ - - Scenario: By default, no specs are run if they are all filtered out by an inclusion tag - Given a file named "spec/example_spec.rb" with: - """ruby - RSpec.describe "examples" do - it "with no tag" do - end - - it "with no tag as well" do - end - end - """ - When I run `rspec spec/example_spec.rb --tag some_tag` - Then the output should contain "0 examples, 0 failures" - - Scenario: Specs are still run if they are filtered out by an exclusion tag - Given a file named "spec/example_spec.rb" with: - """ruby - RSpec.describe "examples" do - it "with no tag" do - end - - it "with no tag as well" do - end - end - """ - When I run `rspec spec/example_spec.rb --tag ~some_tag` - Then the output should contain "2 examples, 0 failures" - - Scenario: When the `run_all_when_everything_filtered` option is turned on, if there are any matches for the filtering tag, only those features are run - Given a file named "spec/example_spec.rb" with: - """ruby - require "spec_helper" - RSpec.describe "examples" do - it "with no tag", :some_tag => true do - end - - it "with no tag as well" do - end - end - """ - When I run `rspec spec/example_spec.rb --tag some_tag` - Then the output should contain "1 example, 0 failures" - And the output should contain "Run options: include {:some_tag=>true}" - - Scenario: When the `run_all_when_everything_filtered` option is turned on, all the specs are run when the tag has no matches - Given a file named "spec/example_spec.rb" with: - """ruby - require "spec_helper" - RSpec.describe "examples" do - it "with no tag" do - end - - it "with no tag as well" do - end - end - """ - When I run `rspec spec/example_spec.rb --tag some_tag` - Then the output should contain "2 examples, 0 failures" - And the output should contain "All examples were filtered out; ignoring {:some_tag=>true}" - diff --git a/lib/rspec/core/bisect/fork_runner.rb b/lib/rspec/core/bisect/fork_runner.rb index 4641a14429..219f79c9d9 100644 --- a/lib/rspec/core/bisect/fork_runner.rb +++ b/lib/rspec/core/bisect/fork_runner.rb @@ -111,12 +111,6 @@ def run_specs(run_descriptor) c.load_spec_files end - # `announce_filters` has the side effect of implementing the logic - # that honors `config.run_all_when_everything_filtered` so we need - # to call it here. When we remove `run_all_when_everything_filtered` - # (slated for RSpec 4), we can remove this call to `announce_filters`. - @runner.world.announce_filters - @runner.run_specs(@runner.world.ordered_example_groups) latest_run_results = formatter.results diff --git a/lib/rspec/core/configuration.rb b/lib/rspec/core/configuration.rb index 31daea7789..d538f38b70 100644 --- a/lib/rspec/core/configuration.rb +++ b/lib/rspec/core/configuration.rb @@ -302,13 +302,6 @@ def exclude_pattern=(value) attr_writer :profile_examples define_predicate :profile_examples - # @macro add_setting - # Run all examples if none match the configured filters - # (default: `false`). - # @deprecated Use {#filter_run_when_matching} instead for the specific - # filters that you want to be ignored if none match. - add_setting :run_all_when_everything_filtered - # @macro add_setting # Color to use to indicate success. Defaults to `:green` but can be set # to one of the following: `[:black, :white, :red, :green, :yellow, diff --git a/lib/rspec/core/world.rb b/lib/rspec/core/world.rb index d4b338ea93..3e444aa1f4 100644 --- a/lib/rspec/core/world.rb +++ b/lib/rspec/core/world.rb @@ -175,12 +175,6 @@ def announce_filters end end - if @configuration.run_all_when_everything_filtered? && example_count.zero? && !@configuration.only_failures? - report_filter_message("#{everything_filtered_message}; ignoring #{inclusion_filter.description}") - filtered_examples.clear - inclusion_filter.clear - end - return unless example_count.zero? example_groups.clear diff --git a/spec/integration/bisect_runners_spec.rb b/spec/integration/bisect_runners_spec.rb index 46c04ae1e9..6c4cc4a0f0 100644 --- a/spec/integration/bisect_runners_spec.rb +++ b/spec/integration/bisect_runners_spec.rb @@ -50,27 +50,6 @@ def with_runner(&block) end end - it 'honors `run_all_when_everything_filtered`' do - write_file 'spec/a_spec.rb', " - RSpec.configure do |c| - c.filter_run :focus - c.run_all_when_everything_filtered = true - end - - RSpec.describe 'A group' do - it('passes') { expect(1).to eq 1 } - it('fails') { expect(1).to eq 2 } - end - " - - with_runner do |runner| - expect(runner.original_results).to have_attributes( - :all_example_ids => %w[ ./spec/a_spec.rb[1:1] ./spec/a_spec.rb[1:2] ], - :failed_example_ids => %w[ ./spec/a_spec.rb[1:2] ] - ) - end - end - it 'raises BisectFailedError with all run output when it encounters an error loading spec files' do write_file 'spec/a_spec.rb', " puts 'stdout in a_spec' diff --git a/spec/rspec/core/configuration_spec.rb b/spec/rspec/core/configuration_spec.rb index 9bf807e1d7..422ea469d9 100644 --- a/spec/rspec/core/configuration_spec.rb +++ b/spec/rspec/core/configuration_spec.rb @@ -1293,17 +1293,6 @@ def metadata_hash(*args) end - describe "#run_all_when_everything_filtered?" do - it "defaults to false" do - expect(config.run_all_when_everything_filtered?).to be(false) - end - - it "can be queried by predicate method" do - config.run_all_when_everything_filtered = true - expect(config.run_all_when_everything_filtered?).to be(true) - end - end - describe "#color_mode" do context ":automatic" do before do diff --git a/spec/rspec/core/world_spec.rb b/spec/rspec/core/world_spec.rb index 7c0b52a3e4..f1ce2b5db2 100644 --- a/spec/rspec/core/world_spec.rb +++ b/spec/rspec/core/world_spec.rb @@ -217,19 +217,6 @@ def preceding_declaration_line(line_num) context "when --only-failures is passed" do before { configuration.force(:only_failures => true) } - context "and all examples are filtered out" do - before do - configuration.filter_run_including :foo => 'bar' - end - - it 'will ignore run_all_when_everything_filtered' do - configuration.run_all_when_everything_filtered = true - expect(world.filtered_examples).to_not receive(:clear) - expect(world.inclusion_filter).to_not receive(:clear) - world.announce_filters - end - end - context "and `example_status_persistence_file_path` is not configured" do it 'aborts with a message explaining the config option must be set first' do configuration.example_status_persistence_file_path = nil @@ -287,16 +274,6 @@ def preceding_declaration_line(line_num) end end - context "with an inclusion filter and run_all_when_everything_filtered" do - it "announces" do - allow(configuration).to receive(:run_all_when_everything_filtered?) { true } - configuration.filter_run_including :foo => 'bar' - expect(reporter).to receive(:message). - with(/All examples were filtered out/) - world.announce_filters - end - end - context "with an exclusion filter" do it "announces" do configuration.filter_run_excluding :foo => 'bar'