|
12 | 12 | scope.method(function_name)
|
13 | 13 | end
|
14 | 14 |
|
15 |
| - describe "with an explicit failure message" do |
16 |
| - it "prints the failure message on error" do |
17 |
| - expect { |
18 |
| - subject.call ['', '/bin/false', 'failure message!'] |
19 |
| - }.to raise_error Puppet::ParseError, /failure message!/ |
| 15 | + context 'with no % placeholder' do |
| 16 | + describe "with an explicit failure message" do |
| 17 | + it "prints the failure message on error" do |
| 18 | + expect { |
| 19 | + subject.call ['', '/bin/false', 'failure message!'] |
| 20 | + }.to raise_error Puppet::ParseError, /failure message!/ |
| 21 | + end |
20 | 22 | end
|
21 |
| - end |
22 | 23 |
|
23 |
| - describe "on validation failure" do |
24 |
| - it "includes the command error output" do |
25 |
| - expect { |
26 |
| - subject.call ['', "#{TOUCHEXE} /cant/touch/this"] |
27 |
| - }.to raise_error Puppet::ParseError, /(cannot touch|o such file or)/ |
| 24 | + describe "on validation failure" do |
| 25 | + it "includes the command error output" do |
| 26 | + expect { |
| 27 | + subject.call ['', "#{TOUCHEXE} /cant/touch/this"] |
| 28 | + }.to raise_error Puppet::ParseError, /(cannot touch|o such file or)/ |
| 29 | + end |
| 30 | + |
| 31 | + it "includes the command return value" do |
| 32 | + expect { |
| 33 | + subject.call ['', '/cant/run/this'] |
| 34 | + }.to raise_error Puppet::ParseError, /returned 1\b/ |
| 35 | + end |
28 | 36 | end
|
29 | 37 |
|
30 |
| - it "includes the command return value" do |
31 |
| - expect { |
32 |
| - subject.call ['', '/cant/run/this'] |
33 |
| - }.to raise_error Puppet::ParseError, /returned 1\b/ |
| 38 | + describe "when performing actual validation" do |
| 39 | + it "can positively validate file content" do |
| 40 | + expect { subject.call ["non-empty", "#{TESTEXE} -s"] }.to_not raise_error |
| 41 | + end |
| 42 | + |
| 43 | + it "can negatively validate file content" do |
| 44 | + expect { |
| 45 | + subject.call ["", "#{TESTEXE} -s"] |
| 46 | + }.to raise_error Puppet::ParseError, /failed to validate.*test -s/ |
| 47 | + end |
34 | 48 | end
|
35 | 49 | end
|
36 | 50 |
|
37 |
| - describe "when performing actual validation" do |
38 |
| - it "can positively validate file content" do |
39 |
| - expect { subject.call ["non-empty", "#{TESTEXE} -s"] }.to_not raise_error |
| 51 | + context 'with % placeholder' do |
| 52 | + describe "with an explicit failure message" do |
| 53 | + it "prints the failure message on error" do |
| 54 | + expect { |
| 55 | + subject.call ['', '/bin/false % -f', 'failure message!'] |
| 56 | + }.to raise_error Puppet::ParseError, /failure message!/ |
| 57 | + end |
40 | 58 | end
|
| 59 | + describe "on validation failure" do |
| 60 | + it "includes the command error output" do |
| 61 | + expect { |
| 62 | + subject.call ['', "#{TOUCHEXE} /cant/touch/this"] |
| 63 | + }.to raise_error Puppet::ParseError, /(cannot touch|o such file or)/ |
| 64 | + end |
| 65 | + |
| 66 | + it "includes the command return value" do |
| 67 | + expect { |
| 68 | + subject.call ['', '/cant/run/this % -z'] |
| 69 | + }.to raise_error Puppet::ParseError, /Execution of '\/cant\/run\/this .+ -z' returned 1/ |
| 70 | + end |
| 71 | + end |
| 72 | + |
| 73 | + describe "when performing actual validation" do |
| 74 | + it "can positively validate file content" do |
| 75 | + expect { subject.call ["non-empty", "#{TESTEXE} -s %"] }.to_not raise_error |
| 76 | + end |
41 | 77 |
|
42 |
| - it "can negatively validate file content" do |
43 |
| - expect { |
44 |
| - subject.call ["", "#{TESTEXE} -s"] |
45 |
| - }.to raise_error Puppet::ParseError, /failed to validate.*test -s/ |
| 78 | + it "can negatively validate file content" do |
| 79 | + expect { |
| 80 | + subject.call ["", "#{TESTEXE} -s %"] |
| 81 | + }.to raise_error Puppet::ParseError, /failed to validate.*test -s/ |
| 82 | + end |
46 | 83 | end
|
47 | 84 | end
|
48 | 85 | end
|
0 commit comments