I know that I can mock objects as follows:
Account.any_instance.expects(:type).returns("premium")
I remember hearing that this is considered a poor practice. I'd love to do something like
user = users(:bob)
user.account.expects(:type).returns("premium")
but this doesn't seem to mock the right object. Is there a better solution than using any_instance
call on the class?
Edit: the error message that I'm getting is
not all expectations were satisfied
unsatisfied expectations:
- expected exactly once, not yet invoked: #<Account:0x5f9f8f8>.type(any_parameters)