File tree 1 file changed +7
-4
lines changed
spec/unit/puppet/parser/functions
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
2
3
+ TESTEXE = File . exists? ( '/usr/bin/test' ) ? '/usr/bin/test' : '/bin/test'
4
+ TOUCHEXE = File . exists? ( '/usr/bin/touch' ) ? '/usr/bin/touch' : '/bin/touch'
5
+
3
6
describe Puppet ::Parser ::Functions . function ( :validate_cmd ) do
4
7
let ( :scope ) { PuppetlabsSpec ::PuppetInternals . scope }
5
8
19
22
describe "on validation failure" do
20
23
it "includes the command error output" do
21
24
expect {
22
- subject . call [ '' , '/bin/touch /cant/touch/this' ]
23
- } . to raise_error Puppet ::ParseError , /cannot touch/
25
+ subject . call [ '' , " #{ TOUCHEXE } /cant/touch/this" ]
26
+ } . to raise_error Puppet ::ParseError , /( cannot touch|o such file or) /
24
27
end
25
28
26
29
it "includes the command return value" do
32
35
33
36
describe "when performing actual validation" do
34
37
it "can positively validate file content" do
35
- expect { subject . call [ "non-empty" , "/usr/bin/test -s" ] } . to_not raise_error
38
+ expect { subject . call [ "non-empty" , "#{ TESTEXE } -s" ] } . to_not raise_error
36
39
end
37
40
38
41
it "can negatively validate file content" do
39
42
expect {
40
- subject . call [ "" , "/usr/bin/test -s" ]
43
+ subject . call [ "" , "#{ TESTEXE } -s" ]
41
44
} . to raise_error Puppet ::ParseError , /failed to validate.*test -s/
42
45
end
43
46
end
You can’t perform that action at this time.
0 commit comments