Default spec_helper configuration generated by 'rspec --init' is non-intuitive #796

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+29 −2
Diff settings

Always

Just for now

@@ -48,9 +48,26 @@ def create_spec_helper_file
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
+ # Specify metadata using just symbols. Each symbol used will effectively be
+ # treated as a `true` value, allowing easier filtering when running specs.
+ # it 'can be filtered using simple metadata', :fast, :simple do
+ # end
+ #
+ # rspec -t fast
+ #
config.treat_symbols_as_metadata_keys_with_true_values = true
- config.run_all_when_everything_filtered = true
- config.filter_run :focus
+
+ # Run all specs when none match the provided filter. This works well in
+ # conjunction with `config.filter_run :focus`, as it will run the entire
+ # suite when no specs have `:filter` metadata.
+ #
+ # config.run_all_when_everything_filtered = true
+
+ # Limit the spec run to only specs with the focus metadata. If no specs have
+ # the filtering metadata and `run_all_when_everything_filtered = true` then
+ # all specs will run.
+ #
+ # config.filter_run :focus
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
@@ -49,6 +49,16 @@ module RSpec::Core
command_line_config.run
expect(File.read('spec/spec_helper.rb')).to match /RSpec\.configure do \|config\|/m
end
+
+ it "leaves 'run_all_when_everything_filtered' commented out" do
+ command_line_config.run
+ expect(File.read('spec/spec_helper.rb')).to match /^\s\s# config\.run_all_when_everything_filtered = true/m
+ end
+
+ it "leaves 'filter_run' commented out" do
+ command_line_config.run
+ expect(File.read('spec/spec_helper.rb')).to match /^\s\s# config\.filter_run :focus/m
+ end
end
context "with a spec/spec_helper.rb file" do