2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/bash"
|
2016-04-18 12:47:27 +00:00
|
|
|
|
2019-05-21 00:19:38 +00:00
|
|
|
describe "Inspec::Resources::Bash" do
|
2016-04-18 12:47:27 +00:00
|
|
|
let(:x) { rand.to_s }
|
2019-06-11 22:24:35 +00:00
|
|
|
let(:resource) { load_resource("bash", '$("' + x + '")') }
|
2016-04-18 12:47:27 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "prints as a bash command" do
|
|
|
|
resource.to_s.must_equal 'Bash command $("' + x + '")'
|
2016-04-18 12:47:27 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "wraps the command" do
|
2016-04-18 12:47:27 +00:00
|
|
|
resource.command.must_equal "bash -c \\$\\(\\\"#{x}\\\"\\)"
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "can specify an executable path" do
|
|
|
|
resource = load_resource("bash", '$("' + x + '")', path: "/bin/bash")
|
2016-04-18 12:47:27 +00:00
|
|
|
resource.command.must_equal "/bin/bash -c \\$\\(\\\"#{x}\\\"\\)"
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "can specify a arguments" do
|
|
|
|
resource = load_resource("bash", '$("' + x + '")', args: "-x -c")
|
2016-04-18 12:47:27 +00:00
|
|
|
resource.command.must_equal "bash -x -c \\$\\(\\\"#{x}\\\"\\)"
|
|
|
|
end
|
|
|
|
end
|