I had an exchange with Tommy via email, following up here, as instructed:
In the final problem, my code should work, but throws an error. My code is
# Write a method that returns the integer remainder of its two arguments.
# (i.e., what using the modulo operator would return).
# You may not use the modulo operator.
# Assume the arguments are integers.
# HINT: Use dec_remainder_of_two_integers as a helper method
def int_remainder_without_modulo(i_dividend, i_divisor)
var = i_dividend / i_divisor
return i_dividend - (i_divisor * var)
end
I also have no idea what to make out of the error saying
Failures:
1) methods.rb int_remainder_without_modulo doesn't use the % operator
Failure/Error: return i_dividend - (i_divisor * var)
TypeError:
coerce must return [x, y]
Tommy says: Hey Chris, your code looks like it should work. The problem is with
the spec itself. If you look at the code in the spec, the i_dividend
that’s getting sent in as an argument isn’t actually an integer. It’s
an RSpec::Mocks::Double. It’s basically a dummy stand-in. If you take
a look at the hint in the comment above the method definition, that
might point you in the right direction.
Does this mean my code works fine, but I can’t use it, because I don’t use the helper function it wants me to use?