Skip to content

Commit 4750ea8

Browse files
committed
disable matcher chaining
1 parent 87ebd2a commit 4750ea8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/rspec/rails/matchers/have_reported_error.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def with(expected_attributes)
3434
self
3535
end
3636

37+
def and(_)
38+
raise ArgumentError, "Chaining is not supported"
39+
end
40+
3741
def matches?(block)
3842
if block.nil?
3943
raise ArgumentError, "block is required for have_reported_error matcher"

spec/rspec/rails/matchers/have_reported_error_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ class AnotherTestError < StandardError; end
164164

165165
it "works with matcher chaining" do
166166
expect {
167-
Rails.error.report(TestError.new("test"), context: { user_id: 123 })
168-
}.to have_reported_error(TestError).and have_reported_error
167+
expect {
168+
Rails.error.report(TestError.new("test"))
169+
}.to have_reported_error(TestError).and have_reported_error
170+
}.to raise_error(ArgumentError, "Chaining is not supported")
169171
end
170172
end
171173
end

0 commit comments

Comments
 (0)