Skip to content

Instantly share code, notes, and snippets.

@tcrayford
Created April 19, 2012 11:02
Show Gist options
  • Save tcrayford/2420252 to your computer and use it in GitHub Desktop.
Save tcrayford/2420252 to your computer and use it in GitHub Desktop.
specify "the first time rspec has made me sad" do
class CustomError < RuntimeError; end
expect do
raise CustomError.new('what')
end.to raise_error(CustomError.new('what'))
end
@dasch
Copy link

dasch commented Apr 19, 2012

raise_error?

@tcrayford
Copy link
Author

Still fails. Thanks though.

@dasch
Copy link

dasch commented Apr 19, 2012

You can't give raise_error an instance - it needs to be an exception type: raise_error(CustomError).

@tcrayford
Copy link
Author

It sorta makes sense, assuming Exceptions don't implement == well.

@dasch
Copy link

dasch commented Apr 19, 2012

I think === is used to match exceptions - also by rescue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment