Skip to content

Commit

Permalink
Fix warnings triggered by raise_error matcher
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
tawan committed Oct 16, 2015
1 parent b67e155 commit d3ad8df
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions spec/shoryuken/middleware/server/auto_delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def build_message
expect(sqs_queue).to_not receive(:delete_messages)

expect {
subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise }
}.to raise_error
subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise "Error" }
}.to raise_error(RuntimeError, "Error")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
it 'does not retry the job by default' do
expect(sqs_msg).not_to receive(:change_visibility)

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

it 'does not retry the job if :retry_intervals is empty' do
TestWorker.get_shoryuken_options['retry_intervals'] = []

expect(sqs_msg).not_to receive(:change_visibility)

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

it 'retries the job if :retry_intervals is non-empty' do
Expand Down
4 changes: 2 additions & 2 deletions spec/shoryuken/middleware/server/timing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
end

expect {
subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise }
}.to raise_error
subject.call(TestWorker.new, queue, sqs_msg, sqs_msg.body) { raise "Error" }
}.to raise_error(RuntimeError, "Error")
end
end
end
2 changes: 1 addition & 1 deletion spec/shoryuken/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
end
end
end
Expand Down

0 comments on commit d3ad8df

Please sign in to comment.