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 warnings triggered by raise_error matcher #144

Merged
merged 1 commit into from
Oct 19, 2015

Conversation

tawan
Copy link
Contributor

@tawan tawan commented Oct 16, 2015

Fix warnings that are triggered when the raise_error matcher
is used without providing a specific error class or message.

The warning quoted:

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. Instead consider providing a specific error class or message. This
message can be supressed by setting:
RSpec::Expectations.configuration.warn_about_potential_false_positives = false.

@@ -299,7 +299,7 @@ def perform(sqs_msg, body); end
it 'does not extend the message invisibility' do
expect(sqs_msg).to receive(:visibility_timeout=).never
expect_any_instance_of(TestWorker).to receive(:perform).and_raise 'worker failed'
expect { subject.process(queue, sqs_msg) }.to raise_error
expect { subject.process(queue, sqs_msg) }.to raise_error(RuntimeError, "worker failed")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer single-quoted strings when you don't need string interpolation or special symbols.

Fix warnings that are triggered when the `raise_error` matcher
is used without providing a specific error class or message.

The warning quoted:
>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. Instead consider providing a specific error class or message. This
>message can be supressed by setting:
>`RSpec::Expectations.configuration.warn_about_potential_false_positives =
>false`.
@@ -33,7 +35,9 @@

expect(sqs_msg).not_to receive(:change_visibility)

expect { subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise } }.to raise_error
expect {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using {...} for multi-line blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phstc Even though @houndci is complaining, I left it as is, since you use curly brackets in other parts as well. I hope that's fine for you.

phstc added a commit that referenced this pull request Oct 19, 2015
Fix warnings triggered by raise_error matcher
@phstc phstc merged commit ceaca90 into ruby-shoryuken:master Oct 19, 2015
@phstc
Copy link
Collaborator

phstc commented Oct 19, 2015

Cool. Added to master 🍻

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

Successfully merging this pull request may close these issues.

3 participants