user1291365 user1291365 - 3 years ago 161
Ruby Question

rspec: raise_error usage to match error message

I raised an error using


I tried to test this with rspec:

expect {
}.to raise_error(ConfigurationError, message)

But this doesn't work. How can I test this? The goal is to match

Answer Source

Make sure you are using rspec > 2.14.0 and take a look at this commit:

it "passes if an error instance is expected" do
  s =
  expect {raise s}.to raise_error(s)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download