Skip to content

Commit

Permalink
The actual error depends on whether min or max fails
Browse files Browse the repository at this point in the history
* Interestingly the previous commit worked fine on Ruby 2.7.2 on Linux but failed on macOS.
  • Loading branch information
eregon committed Nov 13, 2020
1 parent 2b4545b commit 059711a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions core/range/minmax_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@

-> { range.minmax }.should raise_error(RangeError, 'cannot get the maximum of endless range')
end
end

ruby_version_is '2.7'...'3.0' do
it 'raises ArgumentError on a beginless range' do
range = Range.new(nil, @x)

-> { range.minmax }.should raise_error(ArgumentError)
end
end

ruby_version_is '3.0' do
it 'should raise RangeError on a beginless range' do
it 'raises RangeError or ArgumentError on a beginless range' do
range = Range.new(nil, @x)

-> { range.minmax }.should raise_error(RangeError, 'cannot get the minimum of beginless range')
-> { range.minmax }.should raise_error(StandardError) { |e|
if RangeError === e
# error from #min
-> { raise e }.should raise_error(RangeError, 'cannot get the minimum of beginless range')
else
# error from #max
-> { raise e }.should raise_error(ArgumentError, 'comparison of NilClass with MockObject failed')
end
}
end
end

Expand Down

0 comments on commit 059711a

Please sign in to comment.