This week-end I’ve upgraded all tests (1000+) in one of my projects from old RSpec 2.14 to RSpec 3.4. I did this according to RSpec site. It went all good - except for CarrierWave tests, which relies on a deprecated protocol.

A deprecation warning I’ve also encountered is this one

WARNING: Using the `raise_error` matcher without providing a specific error or 
message risks false positives, since `raise_error` will match when 
Ruby raises a `NoMethodError`, `NameError` or `ArgumentError`,
potentially allowing the expectation to pass without even executing 
the method you are intending to call.

To be quite honest, I’ve never really thought about that but it’s obvious that this advice is wise. So wise that when searching for code not specifying an error and adding one, I’ve stumbled upon that kind of error:

expected ActiveRecord::RecordInvalid, got #<Module::DelegationError: 
Product#prefix delegated to model.prefix, but model is nil:
...

So indeed I was fooled by my test - by my reasoning about it I should say: it passed but it did so for the wrong reason. I thought it was ok but it really wasn’t.

So, the end of the story is: always specify exception when using raise_exception() matcher.