From 059711a1ef9419f0e353c864ba6a15faae26db2b Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 13 Nov 2020 12:32:31 +0100 Subject: [PATCH] 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. --- core/range/minmax_spec.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/core/range/minmax_spec.rb b/core/range/minmax_spec.rb index cea474bbfc..c3973af13f 100644 --- a/core/range/minmax_spec.rb +++ b/core/range/minmax_spec.rb @@ -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