Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions spec/unit/puppet/parser/functions/validate_cmd_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
require 'spec_helper'

TESTEXE = File.exists?('/usr/bin/test') ? '/usr/bin/test' : '/bin/test'
TOUCHEXE = File.exists?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch'

describe Puppet::Parser::Functions.function(:validate_cmd) do
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }

Expand All @@ -19,8 +22,8 @@
describe "on validation failure" do
it "includes the command error output" do
expect {
subject.call ['', '/bin/touch /cant/touch/this']
}.to raise_error Puppet::ParseError, /cannot touch/
subject.call ['', "#{TOUCHEXE} /cant/touch/this"]
}.to raise_error Puppet::ParseError, /(cannot touch|o such file or)/
end

it "includes the command return value" do
Expand All @@ -32,12 +35,12 @@

describe "when performing actual validation" do
it "can positively validate file content" do
expect { subject.call ["non-empty", "/usr/bin/test -s"] }.to_not raise_error
expect { subject.call ["non-empty", "#{TESTEXE} -s"] }.to_not raise_error
end

it "can negatively validate file content" do
expect {
subject.call ["", "/usr/bin/test -s"]
subject.call ["", "#{TESTEXE} -s"]
}.to raise_error Puppet::ParseError, /failed to validate.*test -s/
end
end
Expand Down