Skip to content

Commit 059711a

Browse files
committed
The actual error depends on whether min or max fails
* Interestingly the previous commit worked fine on Ruby 2.7.2 on Linux but failed on macOS.
1 parent 2b4545b commit 059711a

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

core/range/minmax_spec.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,19 @@
3030

3131
-> { range.minmax }.should raise_error(RangeError, 'cannot get the maximum of endless range')
3232
end
33-
end
34-
35-
ruby_version_is '2.7'...'3.0' do
36-
it 'raises ArgumentError on a beginless range' do
37-
range = Range.new(nil, @x)
3833

39-
-> { range.minmax }.should raise_error(ArgumentError)
40-
end
41-
end
42-
43-
ruby_version_is '3.0' do
44-
it 'should raise RangeError on a beginless range' do
34+
it 'raises RangeError or ArgumentError on a beginless range' do
4535
range = Range.new(nil, @x)
4636

47-
-> { range.minmax }.should raise_error(RangeError, 'cannot get the minimum of beginless range')
37+
-> { range.minmax }.should raise_error(StandardError) { |e|
38+
if RangeError === e
39+
# error from #min
40+
-> { raise e }.should raise_error(RangeError, 'cannot get the minimum of beginless range')
41+
else
42+
# error from #max
43+
-> { raise e }.should raise_error(ArgumentError, 'comparison of NilClass with MockObject failed')
44+
end
45+
}
4846
end
4947
end
5048

0 commit comments

Comments
 (0)