Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions core/numeric/quo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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