Reputation: 1505
Need help ;) Here is example of the code:
def some_method
@some_variable = "some logic for a few strings and operations"
end
I want to stub this method like a
controller.stub(:some_method).and_return( ??? )
But @some_variable should be defined also, how I can do that?
Upvotes: 3
Views: 8678
Reputation: 4920
You can stub it like
allow(controller).to receive(:some_method) { your_return_value }
Just using the new syntax for stubbing above.
For your instance variable, you can do
controller.instance_variable_set(:@some_variable, value)
Upvotes: 6