diff options
Diffstat (limited to 'spec/ruby/shared/rational/Rational.rb')
-rw-r--r-- | spec/ruby/shared/rational/Rational.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/ruby/shared/rational/Rational.rb b/spec/ruby/shared/rational/Rational.rb index 2dc49c869c..500f7ed271 100644 --- a/spec/ruby/shared/rational/Rational.rb +++ b/spec/ruby/shared/rational/Rational.rb @@ -85,6 +85,11 @@ describe :kernel_Rational, shared: true do end end + it "raises a ZeroDivisionError if the second argument is 0" do + -> { Rational(1, 0) }.should raise_error(ZeroDivisionError, "divided by 0") + -> { Rational(1, 0.0) }.should raise_error(ZeroDivisionError, "divided by 0") + end + it "raises a TypeError if the first argument is nil" do -> { Rational(nil) }.should raise_error(TypeError) end @@ -138,4 +143,8 @@ describe :kernel_Rational, shared: true do end end end + + it "freezes its result" do + Rational(1).frozen?.should == true + end end |