[rspec-users] should raise_error

David Chelimsky dchelimsky at gmail.com
Thu Sep 25 13:33:14 EDT 2008

On Thu, Sep 25, 2008 at 11:56 AM, Mark Wilden <mark at mwilden.com> wrote:
> On Thu, Sep 25, 2008 at 9:33 AM, Nick Hoffman <nick at deadorange.com> wrote:
>> I noticed in the RSpec documentation that "object.should raise_error"
>> isn't enclosed in a begin..rescue..end :
>> http://rspec.info/rdoc/classes/Spec/Matchers.html#M000420
>> However, when I use #raise_error , I have to rescue it, otherwise an
>> actual exception is raised and the script bails.
>> This:
>> RentalMap.make_marker('asdf').should raise_error(RuntimeError, 'The 1st
>> argument (property) should be a Property')
> You need to send :should to a Proc:
>  lambda { RentalMap.make_marker('asdf') }.should raise_error(blah, blah)
> I'll be every RSpec user has made this mistake at least once (in my case,
> numerous times). I wonder if it would be possible for the matcher to call
> this out?

Anything is possible :)

Please submit a feature request: http://rspec.lighthouseapp.com/


> ///ark

More information about the rspec-users mailing list