Skip to content

Instantly share code, notes, and snippets.

@moser
Created October 30, 2009 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moser/222220 to your computer and use it in GitHub Desktop.
Save moser/222220 to your computer and use it in GitHub Desktop.
# defined in my spec_helper
# requires mocha
# needed because
# mock() { expects(:foo).with(:bar, anything) }
# does not work. (fails with "Mocha::ExpectationError: unexpected invocation: #<Mock:0x1d8>.anything()")
# Usage:
# mock_block() do |m|
# m.expects(:foo).with(:bar, anything)
# end
def mock_block(&block)
m = mock()
yield m if block_given?
m
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment