I would like to be able to chain multiple .with
expectations together. At present I am putting them on separate lines -
foo.expects( :bar ).with( a )
foo.expects( :bar ).with( b )
foo.expects( :bar ).with( c )
With .returns
you can just do -
foo.expects( :bar ).returns( a, b, c )
I would ideally like to be able to -
foo.expects( :bar ).returns( a, b, c ).with( a, b, c )
or
foo.expects( :bar ).returns( a, b, c ).with( a ).with( b ).with( c )
You can't call
with
multiple times in the same expectation becausewith
will override the previous one.It's different with
returns
becausereturns
accumulate the expectations.So, yes, you have to do it in the way you're doing, calling
expects
multiple times in the same object.