From 0f62a3a0a44bf25b6109d70ed4d2f655d3640b3f Mon Sep 17 00:00:00 2001 From: Kenta Murata Date: Fri, 7 Jun 2013 11:53:45 +0900 Subject: [PATCH] Follow CRuby r41109 --- core/numeric/quo_spec.rb | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/core/numeric/quo_spec.rb b/core/numeric/quo_spec.rb index 314a808c76..f7effee8fb 100644 --- a/core/numeric/quo_spec.rb +++ b/core/numeric/quo_spec.rb @@ -28,6 +28,17 @@ lambda { -bignum_value.quo(0) }.should raise_error(ZeroDivisionError) end + it "raises a TypeError when given a non-Integer" do + lambda { + (obj = mock('x')).should_not_receive(:to_int) + 13.quo(obj) + }.should raise_error(TypeError) + lambda { 13.quo("10") }.should raise_error(TypeError) + lambda { 13.quo(:symbol) }.should raise_error(TypeError) + end + end + + ruby_version_is "1.9"..."2.1" do it "returns the result of calling self#/ with other" do obj = NumericSpecs::Subclass.new obj.should_receive(:coerce).twice.and_return([19,19]) @@ -36,14 +47,14 @@ obj.quo(19).should == 20 end + end - it "raises a TypeError when given a non-Integer" do - lambda { - (obj = mock('x')).should_not_receive(:to_int) - 13.quo(obj) - }.should raise_error(TypeError) - lambda { 13.quo("10") }.should raise_error(TypeError) - lambda { 13.quo(:symbol) }.should raise_error(TypeError) - end + ruby_version_is "2.1" do + it "returns the result of calling self#/ with other" do + obj = NumericSpecs::Subclass.new + obj.should_receive(:to_r).and_return(19.quo(20)) + + obj.quo(19).should == 1.quo(20) + end end end