Skip to content

Instantly share code, notes, and snippets.

@myronmarston
Created December 9, 2014 18:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myronmarston/ed664fb995300edd89e2 to your computer and use it in GitHub Desktop.
Save myronmarston/ed664fb995300edd89e2 to your computer and use it in GitHub Desktop.
# you can pass an implementation block, and use expectations in the block:
expect(MyClass).to receive(:method) do |arg_1, arg_2|
expect(arg_1).to eq(2)
expect(arg_2).to eq(3)
end
# or you can wrap any block in the `satisfy` (also aliased to `an_object_satisfying`) to turn it into a matcher:
expect(MyClass).to receive(:method).with(an_object_satisfying { |arg| arg.even? })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment