inspec/test/functional/inspec_init_test.rb
Miah Johnson a084187b21 When a profile is created with init, the last item after a / is the (#3175)
profile name. eg "with/slash" would result in a profile created in the
"with" directory named "slash"

Add test for inspec init, and updated other for new output.

Clean up profiles created during testing and place them in temporary
directories.

Describe our test a bit better.
Check that the profile was created in the right location.
Check that the profile is named correctly.

Signed-off-by: Miah Johnson <miah@chia-pet.org>
2018-07-05 15:37:18 -04:00

23 lines
650 B
Ruby

require 'functional/helper'
require 'fileutils'
require 'tmpdir'
require 'yaml'
describe 'inspec init' do
include FunctionalHelper
tmpdir = Dir.tmpdir
describe 'inspec init profile with/slash' do
it 'names profile with string after last slash' do
slash_profile = "#{tmpdir}/inspecwith/slash"
out = inspec("init profile #{slash_profile}")
out.exit_status.must_equal 0
File.exist?(slash_profile).must_equal true
profile = YAML.load_file("#{slash_profile}/inspec.yml")
profile['name'].must_equal 'slash'
end
end
Dir.glob("#{tmpdir}/inspecwith*").each {|i| FileUtils.remove_entry_secure(i) }
end