Skip to content

Commit 4b86a88

Browse files
committed
(PUP-12029) Ruby 3.3 reports NoMethodError messages differently
Ruby 3.3 changed NoMethodError message format so it no longer calls to_s on our Interface, see ruby commit 1fd181b453a
1 parent 5bce3bb commit 4b86a88

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

spec/unit/interface_spec.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,22 @@
129129
describe 'when raising NoMethodErrors' do
130130
subject { described_class.new(:foo, '1.0.0') }
131131

132-
it 'includes the face name in the error message' do
133-
expect { subject.boombaz }.to raise_error(NoMethodError, /#{subject.name}/)
134-
end
132+
if RUBY_VERSION.to_f >= 3.3
133+
it 'includes the face name in the error message' do
134+
expect { subject.boombaz }.to raise_error(NoMethodError, /for an instance of Puppet::Interface/)
135+
end
136+
137+
it 'includes the face version in the error message' do
138+
expect { subject.boombaz }.to raise_error(NoMethodError, /for an instance of Puppet::Interface/)
139+
end
140+
else
141+
it 'includes the face name in the error message' do
142+
expect { subject.boombaz }.to raise_error(NoMethodError, /#{subject.name}/)
143+
end
135144

136-
it 'includes the face version in the error message' do
137-
expect { subject.boombaz }.to raise_error(NoMethodError, /#{subject.version}/)
145+
it 'includes the face version in the error message' do
146+
expect { subject.boombaz }.to raise_error(NoMethodError, /#{subject.version}/)
147+
end
138148
end
139149
end
140150

0 commit comments

Comments
 (0)