The Clickatell::API::Error takes two arguments to its constructor, an
error code and an error message. Unfortunately, the above code causes
Mocha to choke:
ArgumentError: wrong number of arguments (3 for 2)
./test/functional/sms_message_controller_test.rb:40:in `raises'
So I also tried passing the arguments as an array:
@sms.expects(:create).raises(Clickatell::API::Error, ["001",
"error_message"])
But that causes the Error class to choke:
ArgumentError: wrong number of arguments (1 for 2)
/Users/lesfreeman/Sites/pvpowered/portal/branches/TRY-LF-test_coverage/
config/../vendor/plugins/mocha/lib/mocha/exception_raiser.rb:11:in
`initialize'
It appears that it doesn't try to unwrap the array before passing it
along to the error class.
I'm going to try monkeypatching the error class to take an array for
the initializer, but wanted to check and see if there was something I
was missing about how to get mocha to handle this out of the box.
Thanks!
Les
Hi Les,
You should be able to pass an instance of the exception into Expectation#raises.
I've knocked up a quick example here [1].
I've realised that this is not made clear in the docs - so I've added
a ticket [2] to improve the docs.
I hope that helps,
Cheers, James.
[1] http://pastie.org/874269
[2] http://floehopper.lighthouseapp.com/projects/22289-mocha/tickets/65
On Mar 17, 12:07 pm, James Mead <jamesmea...@gmail.com> wrote: