diff options
Diffstat (limited to 'spec/ruby/core/range')
| -rw-r--r-- | spec/ruby/core/range/fixtures/classes.rb | 3 | ||||
| -rw-r--r-- | spec/ruby/core/range/new_spec.rb | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/core/range/fixtures/classes.rb b/spec/ruby/core/range/fixtures/classes.rb index de46d7d4a9..b62704ca39 100644 --- a/spec/ruby/core/range/fixtures/classes.rb +++ b/spec/ruby/core/range/fixtures/classes.rb @@ -62,4 +62,7 @@ module RangeSpecs class MyRange < Range end + + class ComparisonError < RuntimeError + end end diff --git a/spec/ruby/core/range/new_spec.rb b/spec/ruby/core/range/new_spec.rb index f0d24e4aeb..8ec4605102 100644 --- a/spec/ruby/core/range/new_spec.rb +++ b/spec/ruby/core/range/new_spec.rb @@ -1,4 +1,5 @@ require File.expand_path('../../../spec_helper', __FILE__) +require File.expand_path('../fixtures/classes', __FILE__) describe "Range.new" do it "constructs a range using the given start and end" do @@ -31,4 +32,14 @@ describe "Range.new" do (a = mock('nil')).should_receive(:<=>).with(b).and_return(nil) lambda { Range.new(a, b) }.should raise_error(ArgumentError) end + + ruby_version_is "2.5" do + it "does not rescue exception raised in #<=> when compares the given start and end" do + b = mock('a') + a = mock('b') + a.should_receive(:<=>).with(b).and_raise(RangeSpecs::ComparisonError) + + -> { Range.new(a, b) }.should raise_error(RangeSpecs::ComparisonError) + end + end end |
