inspec/test/unit/resources/ksh_test.rb
Sonu Saha ee8d263b74 CFINSPEC-267: Add resource_id & unit test: ksh
Signed-off-by: Sonu Saha <sonu.saha@progress.com>
2022-06-02 11:31:22 +05:30

27 lines
833 B
Ruby

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