Skip to content

Commit 52706d3

Browse files
Make rule parse failures show useful warnings
By default the test failure output when a rule is unparseable is just `undefined method '[]' for nil:NilClass`, which does not meaningfully indicate that an error has happened in parsing, or which error. This makes any current or future warning from the parser appear in test failure output.
1 parent c230bba commit 52706d3

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

spec/unit/puppet/provider/ip6tables_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ def stub_iptables
101101
# If this option is enabled, make sure the parameters exactly match
102102
if data[:compare_all]
103103
it 'the parameter hash keys should be the same as returned by rules_to_hash' do
104+
expect(provider6).not_to receive(:warning)
104105
expect(resource.keys).to match_array(data[:params].keys)
105106
end
106107
end
107108

108109
# Iterate across each parameter, creating an example for comparison
109110
data[:params].each do |param_name, param_value|
110111
it "the parameter '#{param_name}' should match #{param_value.inspect}" do
112+
expect(provider6).not_to receive(:warning)
111113
if param_value == true
112114
expect(resource[param_name]).to be_truthy
113115
else

spec/unit/puppet/provider/iptables_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,15 @@
219219
# If this option is enabled, make sure the parameters exactly match
220220
if data[:compare_all]
221221
it 'the parameter hash keys should be the same as returned by rules_to_hash' do
222+
expect(provider).not_to receive(:warning)
222223
expect(resource.keys).to match_array(data[:params].keys)
223224
end
224225
end
225226

226227
# Iterate across each parameter, creating an example for comparison
227228
data[:params].each do |param_name, param_value|
228229
it "the parameter '#{param_name}' should match #{param_value.inspect}" do
230+
expect(provider).not_to receive(:warning)
229231
# booleans get cludged to string "true"
230232
if param_value == true
231233
expect(resource[param_name]).to be_truthy

0 commit comments

Comments
 (0)