是否可以使用rspec返回賦給stubbed/mocked方法的參數?rspec模擬返回給定參數
我有種想寫點東西像這樣:
object.should_receive(:foo).with(anything()).and_return(that_thing())
編輯:
我意識到這樣做的一種方式 - 塊的返回值是由方法調用返回的:
object.should_receive(:foo) { |args| args }
請參閱 「收到信息的任意處理」 在http://rspec.info/documentation/mocks/message_expectations.html
也許還有另一種方式?
使用塊這樣的正是這樣做的方式。 – d11wtq