rubocop / rspec-style-guide

Best practices for writing your specs!
http://rspec.rubystyle.guide
953 stars 118 forks source link

Add a Never Check for a Bare Exception guideline #105

Open pirj opened 5 years ago

pirj commented 5 years ago

Taken from Effective Testing with RSpec book. There's a matching RSpec/UnspecifiedException cop in RuboCop-RSpec.

Example problem with it.

The negated form has the opposite problem, and the exception should not be specified, as another exception may appear instead, the example will pass, and the code that is raising the exception in question won't even be run.

andyw8 commented 5 years ago

Worth mentioning the on_potential_false_positives config option?

https://www.andywaite.com/2018/07/15/prevent-false-positives-rspec-error.html

pirj commented 5 years ago

on_potential_false_positives with :raise is awesome 👍