问题
Let's say I have a method that references an instance variable directly:
class MyClass
def method1
puts @instance_var
end
end
How can I stub out the value of @instance_var
using mocha
in a Test::Unit
test?
回答1:
You can't. That's one of the many reasons why you should never access ivars directly.
来源:https://stackoverflow.com/questions/9971192/stub-an-instance-variable-using-mocha