inspec/test/unit/resources/bash_test.rb

29 lines
890 B
Bash
Raw Normal View History

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