jimweirich / rspec-given

Given/When/Then keywords for RSpec Specifications
https://github.com/jimweirich/rspec-given
MIT License
653 stars 61 forks source link

A more elegant way to check the message of an exception? #53

Closed aviflax closed 8 years ago

aviflax commented 8 years ago

I’m using given with MiniTest (and loving it) and this is the only way I’ve figured out to do this:

And do
  # This is awkward but it’s the only way I’ve figured out to capture
  # the exception and use it in an assertion.
  begin
    result.raise_please # will raise the original exception
  rescue RuntimeError => e
    e.message.include? 'not found'
  end
end

I’m new to Ruby though, so I figure I’m probably just missing something… thanks!

docwhat commented 8 years ago

The question is answered in the README. Grep for failure.

Also, I think this repo is deprecated in favor of rspec-given/rspec-given

aviflax commented 8 years ago

@docwhat thanks. I didn’t see it there because the README doesn’t explicitly explain how to check the message with have_failed. And being new to Ruby, I didn’t recognize what was going on with /empty/. So, I’m good. Thank you!