Having an issue passing the final test.
Failures:
- methods.rb int_remainder_without_modulo doesn’t use the % operator
Failure/Error: i_dividend - ((i_dividend / i_divisor) * i_divisor)
#<Double “Integer”> received unexpected message :- with (2)./lib/methods.rb:106:in `int_remainder_without_modulo’
./spec/methods_spec.rb:144:in `block (3 levels) in <top (required)>’
Finished in 0.01033 seconds (files took 0.06687 seconds to load)
27 examples, 1 failure
Failed examples:
rspec ./spec/methods_spec.rb:141 # methods.rb int_remainder_without_modulo doesn’t use the % operator
Here’s my code:
def int_remainder_without_modulo(i_dividend, i_divisor)
i_dividend - ((i_dividend / i_divisor) * i_divisor)
end
And the rspec:
describe “int_remainder_without_modulo” do
it “knows 8 mod 3 is 2” do
expect(int_remainder_without_modulo(8, 3)).to be(2)
end
it "knows 5 mod 6 is 5" do
expect(int_remainder_without_modulo(5, 6)).to eq(5)
end
it "doesn't use the % operator" do
a = double("Integer", :/ => 1, :to_f => 2.0)
expect(a).not_to receive(:%)
int_remainder_without_modulo(a, 2)
end
end
I tried a couple different solutions, and kept getting the same issue. Thx!