PR feedback part 1

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2020-01-28 11:06:12 -05:00
parent 76a9c3e590
commit 357cf051b1
3 changed files with 10 additions and 10 deletions

View file

@ -9,7 +9,7 @@ module Inspec
end end
def self.src_root def self.src_root
@src_root ||= File.expand_path(File.join(__FILE__, "..", "..", "..")) @src_root ||= File.expand_path(File.join(__FILE__, "../../.."))
end end
end end

View file

@ -1,6 +1,6 @@
module Inspec module Inspec
# Hueristics to determine how InSpec was installed. # Heuristics to determine how InSpec was installed.
module InstallContextHelpers module InstallContextHelpers
def guess_install_context def guess_install_context

View file

@ -2,17 +2,17 @@ require "helper"
require "inspec/globals" require "inspec/globals"
require "inspec/utils/install_context" require "inspec/utils/install_context"
def check_install_contexts(test_expected_to_be_true, also_rubygem) def assert_install_contexts(test_expected_to_be_true, also_rubygem)
should_be_false = %w{chef-workstation chefdk docker should_be_false = %w{chef-workstation chefdk docker
habitat omnibus rubygem source} habitat omnibus rubygem source}
should_be_false -= [test_expected_to_be_true] should_be_false -= [test_expected_to_be_true]
should_be_false = should_be_false.map { |m| "#{m}_install?".tr("-", "_").to_sym } should_be_false = should_be_false.map { |m| "#{m}_install?".tr("-", "_").to_sym }
should_be_false -= [:rubygem_install?] if also_rubygem should_be_false -= [:rubygem_install?] if also_rubygem
should_be_false.each { |m| expect(Inspec.method(m).call).must_equal false } should_be_false.each { |m| expect(Inspec.send(m)).must_equal false }
should_be_true = ["#{test_expected_to_be_true}_install?".tr("-", "_").to_sym] should_be_true = ["#{test_expected_to_be_true}_install?".tr("-", "_").to_sym]
should_be_true += [:rubygem_install?] if also_rubygem should_be_true += [:rubygem_install?] if also_rubygem
should_be_true.each { |m| expect(Inspec.method(m).call).must_equal true } should_be_true.each { |m| expect(Inspec.send(m)).must_equal true }
expect(Inspec.guess_install_context).must_equal test_expected_to_be_true expect(Inspec.guess_install_context).must_equal test_expected_to_be_true
end end
@ -25,7 +25,7 @@ describe Inspec::InstallContextHelpers do
end end
it "should properly detect a Docker install" do it "should properly detect a Docker install" do
check_install_contexts("docker", true) assert_install_contexts("docker", true)
end end
end end
@ -35,7 +35,7 @@ describe Inspec::InstallContextHelpers do
end end
it "should properly detect a habitat install" do it "should properly detect a habitat install" do
check_install_contexts("habitat", true) assert_install_contexts("habitat", true)
end end
end end
@ -45,7 +45,7 @@ describe Inspec::InstallContextHelpers do
end end
it "should properly detect a rubygem install" do it "should properly detect a rubygem install" do
check_install_contexts("rubygem", true) assert_install_contexts("rubygem", true)
end end
end end
@ -58,7 +58,7 @@ describe Inspec::InstallContextHelpers do
end end
it "should properly detect a source install" do it "should properly detect a source install" do
check_install_contexts("source", false) assert_install_contexts("source", false)
end end
end end
@ -77,7 +77,7 @@ describe Inspec::InstallContextHelpers do
Inspec.expects(:src_root).at_least_once.returns("#{inst_dir}/#{inst_subdir}/embedded/lib/ruby/gems/2.6.0/gems/inspec-4.18.39") Inspec.expects(:src_root).at_least_once.returns("#{inst_dir}/#{inst_subdir}/embedded/lib/ruby/gems/2.6.0/gems/inspec-4.18.39")
end end
it "should properly detect a #{os_name} #{inst_mode} install" do it "should properly detect a #{os_name} #{inst_mode} install" do
check_install_contexts(inst_mode, true) assert_install_contexts(inst_mode, true)
end end
end end
end end