Guest User

Untitled

a guest
Apr 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. # defined in my spec_helper
  2. # requires mocha
  3. # needed because
  4. # mock() { expects(:foo).with(:bar, anything) }
  5. # does not work. (fails with "Mocha::ExpectationError: unexpected invocation: #<Mock:0x1d8>.anything()")
  6. # Usage:
  7. # mock_block() do |m|
  8. # m.expects(:foo).with(:bar, anything)
  9. # end
  10. def mock_block(&block)
  11. m = mock()
  12. yield m if block_given?
  13. m
  14. end
Add Comment
Please, Sign In to add comment