Skip to content

Instantly share code, notes, and snippets.

@daipresents
Last active March 28, 2017 06:22
Show Gist options
  • Save daipresents/a0be49b8b20fe11460864819228ccb23 to your computer and use it in GitHub Desktop.
Save daipresents/a0be49b8b20fe11460864819228ccb23 to your computer and use it in GitHub Desktop.
expect { }.not_to raise_error(SpecificErrorClass)
WARNING: Using `expect { }.not_to raise_error(SpecificErrorClass)` risks false positives, since literally any other error would cause the expectation to pass, including those raised by Ruby (e.g. NoMethodError, NameError and ArgumentError), meaning the code you are intending to test may not even get reached. Instead consider using `expect {}.not_to raise_error` or `expect { }.to raise_error(DifferentSpecificErrorClass)`. This message can be suppressed by setting: `RSpec::Expectations.configuration.on_potential_false_positives = :nothing`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment