Skip to content

Commit 224b8f9

Browse files
committed
Merge pull request #200 from bobtfish/fix_tests_on_osx
Fix the tests on osx
2 parents 76514d4 + a197869 commit 224b8f9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

spec/unit/puppet/parser/functions/validate_cmd_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
require 'spec_helper'
22

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+
36
describe Puppet::Parser::Functions.function(:validate_cmd) do
47
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
58

@@ -19,8 +22,8 @@
1922
describe "on validation failure" do
2023
it "includes the command error output" do
2124
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)/
2427
end
2528

2629
it "includes the command return value" do
@@ -32,12 +35,12 @@
3235

3336
describe "when performing actual validation" do
3437
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
3639
end
3740

3841
it "can negatively validate file content" do
3942
expect {
40-
subject.call ["", "/usr/bin/test -s"]
43+
subject.call ["", "#{TESTEXE} -s"]
4144
}.to raise_error Puppet::ParseError, /failed to validate.*test -s/
4245
end
4346
end

0 commit comments

Comments
 (0)