Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 3201563

Browse files
committed
Raise for unsupported fail_fast value
1 parent 91203d3 commit 3201563

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Breaking Changes:
1111
* Remove `run_all_when_everything_filtered` configuration option. (Phil Pirozhkov, #2845)
1212
* Raise on unsupported hook scope usage. (Phil Pirozhkov, #2849)
1313
* Raise on usage of metadata on suite-level scopes. (Phil Pirozhkov, #2849)
14+
* Raise an error when `fail_fast` is configured with
15+
an unsupported value. (Phil Pirozhkov, #2849)
1416

1517
Enhancements:
1618

lib/rspec/core/configuration.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,9 @@ def fail_fast=(value)
203203
@fail_fast = value.to_i
204204

205205
if value.to_i == 0
206-
# TODO: in RSpec 4, consider raising an error here.
207-
RSpec.warning "Cannot set `RSpec.configuration.fail_fast`" \
206+
raise ArgumentError, "Cannot set `RSpec.configuration.fail_fast`" \
208207
" to `#{value.inspect}`. Only `true`, `false`, `nil` and integers" \
209208
" are valid values."
210-
@fail_fast = true
211209
end
212210
end
213211
end

spec/rspec/core/configuration_spec.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,10 @@ module RSpec::Core
110110
allow(RSpec).to receive(:warning)
111111
end
112112

113-
it 'prints warning' do
114-
config.fail_fast = 'yes'
115-
expect(RSpec).to have_received(:warning).with(/Cannot set `RSpec.configuration.fail_fast`/i)
116-
end
117-
118-
it 'is set to true' do
119-
config.fail_fast = 'yes'
120-
expect(config.fail_fast).to eq true
113+
it 'raises an error' do
114+
expect {
115+
config.fail_fast = 'yes'
116+
}.to raise_error(ArgumentError, /Cannot set `RSpec.configuration.fail_fast`/i)
121117
end
122118
end
123119
end

0 commit comments

Comments
 (0)