Let's say you have some class like
class Foo
...
public def methodA
x = methodB(true)
# other operations (assume x is not the return value of methodA)
end
private def methodB(arg)
if arg
return 1
else
return 0
end
end
end
When you're writing a unit test for methodA
, you want to check that x
was assigned the right value, which means you have to check that the call to methodB
returned 1
like you expected.
How would you test that in rspec?
Right now I have (with help from How to test if method is called in RSpec but do not override the return value)
@foo = Foo.new
expect(@foo).to receive(:methodB).with(true).and_call_original
But I don't know how to verify the actual return value of methodB
.