Skip to content

Commit 17f2f95

Browse files
committed
improved argument error message in case block is not passed to matcher
1 parent 4750ea8 commit 17f2f95

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/rspec/rails/matchers/have_reported_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def and(_)
4040

4141
def matches?(block)
4242
if block.nil?
43-
raise ArgumentError, "block is required for have_reported_error matcher"
43+
raise ArgumentError, "this matcher doesn’t work with value expectations"
4444
end
4545

4646
@error_subscriber = ErrorSubscriber.new

spec/rspec/rails/matchers/have_reported_error_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AnotherTestError < StandardError; end
1111
it "warns that passing value expectation doesn't work" do
1212
expect {
1313
expect(Rails.error.report(StandardError.new("test error"))).to have_reported_error
14-
}.to raise_error(ArgumentError, "block is required for have_reported_error matcher")
14+
}.to raise_error(ArgumentError, "this matcher doesn’t work with value expectations")
1515
end
1616

1717
describe "basic functionality" do

0 commit comments

Comments
 (0)