RSpec: Messages in Specific Order

Posted . Visible to the public.

tl;dr

You can use ordered to ensure that messages are received in a specific order.

Example

expect(ClassA).to receive(:call_first).ordered
expect(ClassB).to receive(:call_second).ordered
expect(ClassB).to receive(:call_third).ordered

#ordered supports further chaining

Example

Julian
License
Source code in this card is licensed under the MIT License.
Posted by Julian to makandra dev (2023-11-29 09:42)