2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/ksh"
|
2018-10-23 13:16:24 +00:00
|
|
|
|
|
|
|
describe Inspec::Resources::Ksh do
|
|
|
|
let(:x) { rand.to_s }
|
2019-06-11 22:24:35 +00:00
|
|
|
let(:resource) { load_resource("ksh", '$("' + x + '")') }
|
2018-10-23 13:16:24 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "prints as a ksh command" do
|
2019-09-30 22:31:55 +00:00
|
|
|
_(resource.to_s).must_equal 'KornShell command $("' + x + '")'
|
2018-10-23 13:16:24 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "wraps the command" do
|
2019-09-30 22:31:55 +00:00
|
|
|
_(resource.command).must_equal "ksh -c \\$\\(\\\"#{x}\\\"\\)"
|
2018-10-23 13:16:24 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "can specify an executable path" do
|
|
|
|
resource = load_resource("ksh", '$("' + x + '")', path: "/bin/ksh")
|
2019-09-30 22:31:55 +00:00
|
|
|
_(resource.command).must_equal "/bin/ksh -c \\$\\(\\\"#{x}\\\"\\)"
|
2018-10-23 13:16:24 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "can specify a arguments" do
|
|
|
|
resource = load_resource("ksh", '$("' + x + '")', args: "-x -c")
|
2019-09-30 22:31:55 +00:00
|
|
|
_(resource.command).must_equal "ksh -x -c \\$\\(\\\"#{x}\\\"\\)"
|
2018-10-23 13:16:24 +00:00
|
|
|
end
|
|
|
|
end
|