I searched a lot and just canβt understand, although this seems basic. Here is a simplified example of what I want to do.
Create a simple method that does something but returns nothing, for example:
class Test def test_method(param) puts param end test_method("hello") end
But in my rspec test, I need to pass another parameter, for example "goodbye" instead of "hello". I know this is related to stubs and layouts, and I am looking at the documentation, but I canβt understand: https://relishapp.com/rspec/rspec-mocks/v/3-0/docs/method-stubs
If I do this:
@test = Test.new allow(@test).to_receive(:test_method).with("goodbye")
he tells me to cut the default value, but I cannot figure out how to do it correctly.
Error message:
received :test_method with unexpected arguments expected: ("hello") got: ("goodbye") Please stub a default value first if message might be received with other args as well.
I am using rspec 3.0 and calling something like
@test.stub(:test_method)
is not allowed.
ruby mocking rspec stubbing
user3060126
source share