rspec-style-guide icon indicating copy to clipboard operation
rspec-style-guide copied to clipboard

Add a Never Check for a Bare Exception guideline

Open pirj opened this issue 5 years ago • 2 comments

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.

pirj avatar Aug 20 '19 13:08 pirj

Worth mentioning the on_potential_false_positives config option?

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

andyw8 avatar Aug 20 '19 13:08 andyw8

on_potential_false_positives with :raise is awesome 👍

pirj avatar Aug 20 '19 13:08 pirj