moser (owner)

Revisions

gist: 222220 Download_button fork
public
Public Clone URL: git://gist.github.com/222220.git
Embed All Files: show embed
mocha mock generation with block.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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