tags:

views:

28

answers:

1

Here is my code:

account_double.should_receive(:withdraw).and_raise

I get the output:

1) Statement uses the customer's name in the header
Failure/Error: Unable to find matching line from backtrace
Exception
# ./spec/codebreaker/test.rb:8:in `generate'
# ./spec/codebreaker/test.rb:20
# /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `inject'

It cannot find Exception. How could I get this test to pass?

I dont understand the picture

+1  A: 

Try adding an argument to and_raise - either an Exception class or a string to pass to RuntimeError

From the docs:

Tells the mock to raise an exception instead of returning a value. may be any Exception class, an instance of any Exception class, or a String (in which case a RuntimeError will be raised with that String as its message).

account_double.should_receive(:withdraw).and_raise(Exception)
rspeicher