Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Spec Warning: "when the unhandled keys are ignored - does not raise an error" risks false positives #144

Open
nicoledow opened this issue Dec 1, 2023 · 0 comments · May be fixed by #148
Labels

Comments

@nicoledow
Copy link
Contributor

nicoledow commented Dec 1, 2023

When running the test suite ($ rspec), there is a warning that the test for "when the unhandled keys are ignored, it does not raise an error" could result in false positives.

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`. Called from /Users/nicoledow/Development/opex/decanter/spec/decanter/decanter_core_spec.rb:343:in `block (6 levels) in <top (required)>'.

Environment

  • decanter version: 4.0.2
  • ruby version: 2.7.7
  • rails version: N/A

Expected Behavior

  • The test suite passes with no warnings.
  • There is no risk of "false positives" when testing the desired behavior

Current Behavior

There is a warning when running the test suite.

Steps to Reproduce

Run $ rspec and view the warning in the console.

Suggested Solution

Not sure. I think we should refactor the test to remove the warning, and also confirm the tested code is in fact creating the desired behavior (i.e. we don't have a false positive).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant