seattlerb/minitest — Issue #66: Mock: expect method that raise an exception
Author: semaperepelitsa
Created: 2011-11-05 23:03:27+00:00
State: open

I was trying to switch from Mocha to MiniTest Mock. But I haven't find a way to make a mock object to expect some method that raise an exception. For example, here is a simplified version of the test that I have.

```ruby
bank = mock
bank.expects(:exchange_with).raises(Money::Bank::UnknownRate)
assert_equal "N/A", formatted_money(123.to_money(:usd), :aaa, bank)
```
`formatted_money` is returning a string with nice representation of money in the specified currency. But when the currency does not exist bank won't know how to convert the money and will raise an exception. In that case `formatted_money` should just return "N/A".

I have read the minitest/mock.rb and I don't have any ideas how to integrate this in a simple way, unfortunately :-(