Skip to content

Commit f54296d

Browse files
andrykonchineregon
authored andcommitted
Refactor and simplify conditions
1 parent d25ca2c commit f54296d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

core/kernel/Rational_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ def obj.to_int; 1; end
118118
-> { Rational(nil) }.should raise_error(TypeError, "can't convert nil into Rational")
119119
end
120120

121+
it "swallows exception raised in #to_int method" do
122+
object = Object.new
123+
def object.to_int() raise NoMethodError; end
124+
125+
-> { Rational(object) }.should raise_error(TypeError)
126+
-> { Rational(object, 1) }.should raise_error(TypeError)
127+
-> { Rational(1, object) }.should raise_error(TypeError)
128+
end
129+
121130
it "raises TypeError if #to_r does not return Rational" do
122131
obj = Object.new
123132
def obj.to_r; []; end

0 commit comments

Comments
 (0)