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
withmultiple times in the same expectation becausewithwill override the previous one.It's different with
returnsbecausereturnsaccumulate the expectations.So, yes, you have to do it in the way you're doing, calling
expectsmultiple times in the same object.