Posted about 1 month ago. Visible to the public.

RSpec: Expecting multiple calls of the same method

If the argument list is the same every time:

expect(object).to receive(:foo).with('argument').and_return('response 1', 'response 2')

If the argument list differs between invocations:

expect(object).to receive(:foo).with('argument 1').ordered.and_return('response 1') expect(object).to receive(:foo).with('argument 2').ordered.and_return('response 2')

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Author of this card:

Henning Koch
Last edit:
8 days ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev