Skip to content

Commit

Permalink
Raise for unsupported fail_fast value
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Jan 10, 2021
1 parent 32db201 commit a66adfe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Breaking Changes:
* Remove `run_all_when_everything_filtered` configuration option. (Phil Pirozhkov, #2845)
* Raise on unsupported hook scope usage. (Phil Pirozhkov, #????)
* Raise on usage of metadata on suite-level scopes. (Phil Pirozhkov, #????)
* Raise an error when `fail_fast` is configured with
an unsupported value. (Phil Pirozhkov, #????)

Enhancements:

Expand Down
3 changes: 1 addition & 2 deletions lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ def fail_fast=(value)
@fail_fast = value.to_i

if value.to_i == 0
# TODO: in RSpec 4, consider raising an error here.
RSpec.warning "Cannot set `RSpec.configuration.fail_fast`" \
raise ArgumentError, "Cannot set `RSpec.configuration.fail_fast`" \
" to `#{value.inspect}`. Only `true`, `false`, `nil` and integers" \
" are valid values."
@fail_fast = true
Expand Down
12 changes: 4 additions & 8 deletions spec/rspec/core/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,10 @@ module RSpec::Core
allow(RSpec).to receive(:warning)
end

it 'prints warning' do
config.fail_fast = 'yes'
expect(RSpec).to have_received(:warning).with(/Cannot set `RSpec.configuration.fail_fast`/i)
end

it 'is set to true' do
config.fail_fast = 'yes'
expect(config.fail_fast).to eq true
it 'raises an error' do
expect {
config.fail_fast = 'yes'
}.to raise_error(ArgumentError, /Cannot set `RSpec.configuration.fail_fast`/i)
end
end
end
Expand Down

0 comments on commit a66adfe

Please sign in to comment.