Skip to content

Commit 5627237

Browse files
committed
fix(spec): workaround for diff formatted errors in ruby 3.4
1 parent 07e8180 commit 5627237

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

spec/lib/pact/consumer_contract/consumer_contract_spec.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ module Pact
1818
subject { ConsumerContract.from_hash({'foo' => 'bar'}) }
1919

2020
it "raises a helpful error" do
21-
expect { subject }.to raise_error UnrecognizePactFormatError, 'This document does not use a recognised Pact format: {"foo"=>"bar"}'
21+
expected_message = if RUBY_VERSION >= "3.4"
22+
'This document does not use a recognised Pact format: {"foo" => "bar"}'
23+
else
24+
'This document does not use a recognised Pact format: {"foo"=>"bar"}'
25+
end
26+
expect { subject }.to raise_error UnrecognizePactFormatError, expected_message
2227
end
2328
end
2429
end
@@ -125,14 +130,24 @@ module Pact
125130
let(:matches1) { true }
126131
let(:matches2) { true }
127132
it "raises an error" do
128-
expect{ subject.find_interaction(criteria) }.to raise_error "Found more than 1 interaction matching {:description=>/blah/} in pact file between Consumer and Provider."
133+
expected_message = if RUBY_VERSION >= "3.4"
134+
"Found more than 1 interaction matching {description: /blah/} in pact file between Consumer and Provider."
135+
else
136+
"Found more than 1 interaction matching {:description=>/blah/} in pact file between Consumer and Provider."
137+
end
138+
expect{ subject.find_interaction(criteria) }.to raise_error expected_message
129139
end
130140
end
131141
context "when a match is not found" do
132142
let(:matches1) { false }
133143
let(:matches2) { false }
134144
it "raises an error" do
135-
expect{ subject.find_interaction(criteria) }.to raise_error "Could not find interaction matching {:description=>/blah/} in pact file between Consumer and Provider."
145+
expected_message = if RUBY_VERSION >= "3.4"
146+
"Could not find interaction matching {description: /blah/} in pact file between Consumer and Provider."
147+
else
148+
"Could not find interaction matching {:description=>/blah/} in pact file between Consumer and Provider."
149+
end
150+
expect{ subject.find_interaction(criteria) }.to raise_error expected_message
136151
end
137152
end
138153
end

0 commit comments

Comments
 (0)