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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With