summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2020-06-26 11:17:25 -0700
committerGitHub <noreply@github.com>2020-06-26 11:17:25 -0700
commit451cd8e5db0a78b68db7e493f2ff73a473171d8b (patch)
tree403610474b5dd9b08bb89329cbcaee6cd7442212
parent2ddf671999fc5b8261eb1dbf5572fda41bd65851 (diff)
parent8dffd98327782cec61f5e3765789a84c563d85d2 (diff)
downloadchef-451cd8e5db0a78b68db7e493f2ff73a473171d8b.tar.gz
Merge pull request #10074 from chef/lcg/win-unit-test-cherrypick
Pick some of the unit test fixes from #10068
-rw-r--r--spec/support/shared/unit/provider/file.rb20
-rw-r--r--spec/unit/application/solo_spec.rb6
-rw-r--r--spec/unit/client_spec.rb5
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb50
-rw-r--r--spec/unit/data_bag_spec.rb9
-rw-r--r--spec/unit/environment_spec.rb6
-rw-r--r--spec/unit/mixin/powershell_out_spec.rb6
-rw-r--r--spec/unit/provider/batch_spec.rb2
-rw-r--r--spec/unit/resource/chef_client_cron_spec.rb30
-rw-r--r--spec/unit/resource/chef_client_systemd_timer_spec.rb11
-rw-r--r--spec/unit/resource/file/verification_spec.rb3
11 files changed, 92 insertions, 56 deletions
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index 509ab15bb6..f624a6ae44 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -484,19 +484,23 @@ shared_examples_for Chef::Provider::File do
it "raises an exception if any verification fails" do
allow(File).to receive(:directory?).with("C:\\Windows\\system32/cmd.exe").and_return(false)
- provider.new_resource.verify windows? ? "REM" : "true"
- provider.new_resource.verify windows? ? "cmd.exe /c exit 1" : "false"
- msg = "Proposed content for #{provider.new_resource.path} failed verification #{windows? ? "cmd.exe /c exit 1" : "false"}"
- expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, /#{msg}/)
+ allow(provider).to receive(:tempfile).and_return(tempfile)
+ provider.new_resource.verify windows? ? "cmd.exe c exit 1" : "false"
+ provider.new_resource.verify.each do |v|
+ allow(v).to receive(:verify).and_return(false)
+ end
+ expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "does not show verification for sensitive resources" do
allow(File).to receive(:directory?).with("C:\\Windows\\system32/cmd.exe").and_return(false)
- provider.new_resource.verify windows? ? "REM" : "true"
- provider.new_resource.verify windows? ? "cmd.exe /c exit 1" : "false"
+ allow(provider).to receive(:tempfile).and_return(tempfile)
provider.new_resource.sensitive true
- msg = "Proposed content for #{provider.new_resource.path} failed verification [sensitive]\nTemporary file moved to #{backupfile}"
- expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, msg)
+ provider.new_resource.verify windows? ? "cmd.exe c exit 1" : "false"
+ provider.new_resource.verify.each do |v|
+ allow(v).to receive(:verify).and_return(false)
+ end
+ expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed, /sensitive/)
end
end
end
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 01c506c60a..0824f8b5b3 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -164,6 +164,8 @@ describe Chef::Application::Solo do
end
context "in local mode" do
+ let(:root_path) { windows? ? "C:/var/chef" : "/var/chef" }
+
before do
Chef::Config[:solo_legacy_mode] = false
end
@@ -197,10 +199,10 @@ describe Chef::Application::Solo do
end
it "sets the repo path" do
- expect(Chef::Config).to receive(:find_chef_repo_path).and_return("/var/chef")
+ expect(Chef::Config).to receive(:find_chef_repo_path).and_return(root_path)
app.reconfigure
expect(Chef::Config.key?(:chef_repo_path)).to be_truthy
- expect(Chef::Config[:chef_repo_path]).to eq ("/var/chef")
+ expect(Chef::Config[:chef_repo_path]).to eq (root_path)
end
it "runs chef-client in local mode" do
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index 831fe9c9b6..34c0a2c548 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -749,9 +749,12 @@ describe Chef::Client do
context "when any directory of cookbook_path contains no cookbook" do
it "raises CookbookNotFound error" do
+ invalid_cookbook_path = windows? ? "C:/path/to/invalid/cookbook_path" : "/path/to/invalid/cookbook_path"
+ msg = "None of the cookbook paths set in Chef::Config[:cookbook_path], [\"#{invalid_cookbook_path}\"], contain any cookbooks"
+
expect do
client.send(:assert_cookbook_path_not_empty, nil)
- end.to raise_error(Chef::Exceptions::CookbookNotFound, 'None of the cookbook paths set in Chef::Config[:cookbook_path], ["/path/to/invalid/cookbook_path"], contain any cookbooks')
+ end.to raise_error(Chef::Exceptions::CookbookNotFound, msg)
end
end
end
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index 0762a11771..a1d312836b 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -217,6 +217,8 @@ describe Chef::CookbookSynchronizer do
path: "/tmp/cookbook_a_template_default_tempfile")
end
+ let(:root) { windows? ? "C:/file-cache/cookbooks/cookbook_a" : "/file-cache/cookbooks/cookbook_a" }
+
def setup_common_files_missing_expectations
# Files are not in the cache:
expect(file_cache).to receive(:key?)
@@ -234,7 +236,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
# Fetch and copy default.rb attribute file
expect(server_api).to receive(:streaming_request)
@@ -244,7 +246,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
end
def setup_no_lazy_files_and_templates_missing_expectations
@@ -262,7 +264,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
expect(server_api).to receive(:streaming_request)
.with("http://chef.example.com/ffffff")
@@ -271,7 +273,7 @@ describe Chef::CookbookSynchronizer do
.with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
end
def setup_common_files_chksum_mismatch_expectations
@@ -292,11 +294,11 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
# Current file has fff000, want abc123
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .with("#{root}/recipes/default.rb")
.and_return("fff000").at_least(:once)
# Fetch and copy default.rb attribute file
@@ -308,11 +310,11 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
# Current file has fff000, want abc456
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .with("#{root}/attributes/default.rb")
.and_return("fff000").at_least(:once)
end
@@ -334,7 +336,7 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
# Fetch and copy apache2.conf template
expect(server_api).to receive(:streaming_request)
@@ -345,16 +347,16 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
# Current file has fff000
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .with("#{root}/default/megaman.conf")
.and_return("fff000")
# Current file has fff000
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .with("#{root}/templates/default/apache2.conf.erb")
.and_return("fff000")
end
@@ -369,23 +371,23 @@ describe Chef::CookbookSynchronizer do
# Current file has abc123, want abc123
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .with("#{root}/recipes/default.rb")
.and_return("abc123").at_least(:once)
# Current file has abc456, want abc456
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .with("#{root}/attributes/default.rb")
.and_return("abc456").at_least(:once)
# :load called twice
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
end
def setup_no_lazy_files_and_templates_present_expectations
@@ -399,23 +401,23 @@ describe Chef::CookbookSynchronizer do
# Current file has abc124, want abc124
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .with("#{root}/default/megaman.conf")
.and_return("abc124")
# Current file has abc125, want abc125
expect(Chef::CookbookVersion).to receive(:checksum_cookbook_file)
- .with("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .with("#{root}/templates/default/apache2.conf.erb")
.and_return("abc125")
# :load called twice
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
+ .and_return("#{root}/default/megaman.conf")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.twice
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
end
describe "#server_api" do
@@ -535,19 +537,19 @@ describe Chef::CookbookSynchronizer do
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/recipes/default.rb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/recipes/default.rb")
+ .and_return("#{root}/recipes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/attributes/default.rb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/attributes/default.rb")
+ .and_return("#{root}/attributes/default.rb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
+ .and_return("#{root}/templates/default/apache2.conf.erb")
expect(file_cache).to receive(:load)
.with("cookbooks/cookbook_a/files/default/megaman.conf", false)
.once
- .and_return("/file-cache/cookbooks/cookbook_a/files/default/megaman.conf")
+ .and_return("#{root}/files/default/megaman.conf")
expect(Chef::Log).to receive(:warn)
.with("skipping cookbook synchronization! DO NOT LEAVE THIS ENABLED IN PRODUCTION!!!")
.once
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index 7e5ef46d58..2a7ddddd5b 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -240,20 +240,23 @@ describe Chef::DataBag do
it "should raise an error if the configured data_bag_path is invalid" do
file_dir_stub(@paths.first, false)
+ msg = "Data bag path '#{windows? ? "C:/var/chef" : "/var/chef"}/data_bags' not found. Please create this directory."
expect do
Chef::DataBag.load("foo")
- end.to raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' not found. Please create this directory."
+ end.to raise_error Chef::Exceptions::InvalidDataBagPath, msg
end
end
describe "data bag with string path" do
- it_should_behave_like "data bag in solo mode", "/var/chef/data_bags"
+ it_should_behave_like "data bag in solo mode", "#{windows? ? "C:/var/chef" : "/var/chef"}/data_bags"
end
describe "data bag with array path" do
- it_should_behave_like "data bag in solo mode", ["/var/chef/data_bags", "/var/chef/data_bags_2"]
+ it_should_behave_like "data bag in solo mode", %w{data_bags data_bags_2}.map { |data_bag|
+ "#{windows? ? "C:/var/chef" : "/var/chef"}/#{data_bag}"
+ }
end
end
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index 2918a9a65e..93b4a5011c 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -454,7 +454,11 @@ describe Chef::Environment do
expect do
Chef::Environment.load("foo")
- end.to raise_error Chef::Exceptions::InvalidEnvironmentPath, "Environment path '/var/chef/environments' is invalid"
+ end.to raise_error(
+ an_instance_of(Chef::Exceptions::InvalidEnvironmentPath).and having_attributes(
+ message: "Environment path '#{windows? ? "C:/var/chef/environments" : "/var/chef/environments"}' is invalid"
+ )
+ )
end
it "should raise an error if the file does not exist" do
diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb
index e6a9186a77..7306332057 100644
--- a/spec/unit/mixin/powershell_out_spec.rb
+++ b/spec/unit/mixin/powershell_out_spec.rb
@@ -30,8 +30,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
it "runs a command and returns the shell_out object" do
ret = double("Mixlib::ShellOut")
expect(object).to receive(:shell_out).with(
- "powershell.exe #{flags} -Command \"Get-Process\"",
- {}
+ "powershell.exe #{flags} -Command \"Get-Process\""
).and_return(ret)
expect(object.powershell_out("Get-Process")).to eql(ret)
end
@@ -62,8 +61,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
it "runs a command and returns the shell_out object" do
mixlib_shellout = double("Mixlib::ShellOut")
expect(object).to receive(:shell_out).with(
- "powershell.exe #{flags} -Command \"Get-Process\"",
- {}
+ "powershell.exe #{flags} -Command \"Get-Process\""
).and_return(mixlib_shellout)
expect(mixlib_shellout).to receive(:error!)
expect(object.powershell_out!("Get-Process")).to eql(mixlib_shellout)
diff --git a/spec/unit/provider/batch_spec.rb b/spec/unit/provider/batch_spec.rb
index 3ca1334489..80e914beaa 100644
--- a/spec/unit/provider/batch_spec.rb
+++ b/spec/unit/provider/batch_spec.rb
@@ -94,7 +94,7 @@ describe Chef::Provider::Batch do
end
describe "#command" do
- let(:basepath) { "C:\\Windows\\system32" }
+ let(:basepath) { "C:\\Windows\\system32\\" }
let(:interpreter) { File.join(basepath, "cmd.exe") }
before do
diff --git a/spec/unit/resource/chef_client_cron_spec.rb b/spec/unit/resource/chef_client_cron_spec.rb
index f1261917a4..b6b28329a9 100644
--- a/spec/unit/resource/chef_client_cron_spec.rb
+++ b/spec/unit/resource/chef_client_cron_spec.rb
@@ -76,13 +76,19 @@ describe Chef::Resource::ChefClientCron do
allow(provider).to receive(:splay_sleep_time).and_return("123")
end
+ let(:root_path) { windows? ? "C:\\chef/client.rb" : "/etc/chef/client.rb" }
+
it "creates a valid command if using all default properties" do
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef/client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/chef/client.log"
+ )
end
it "uses daemon_options if set" do
resource.daemon_options ["--foo 1", "--bar 2"]
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -c /etc/chef/client.rb -L /var/log/chef/client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -c #{root_path} -L /var/log/chef/client.log"
+ )
end
it "uses custom config dir if set" do
@@ -93,27 +99,37 @@ describe Chef::Resource::ChefClientCron do
it "uses custom log files / paths if set" do
resource.log_file_name "my-client.log"
resource.log_directory "/var/log/my-chef/"
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb -L /var/log/my-chef/my-client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/my-chef/my-client.log"
+ )
end
it "uses mailto if set" do
resource.mailto "bob@example.com"
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef/client.log || echo \"Chef Infra Client execution failed\"")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/chef/client.log || echo \"Chef Infra Client execution failed\""
+ )
end
it "uses custom chef-client binary if set" do
resource.chef_binary_path "/usr/local/bin/chef-client"
- expect(provider.cron_command).to eql("/bin/sleep 123; /usr/local/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef/client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /usr/local/bin/chef-client -c #{root_path} -L /var/log/chef/client.log"
+ )
end
it "appends to the log file appending if set to false" do
resource.append_log_file false
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb > /var/log/chef/client.log 2>&1")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} > /var/log/chef/client.log 2>&1"
+ )
end
it "sets the license acceptance flag if set" do
resource.accept_chef_license true
- expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/chef/client.rb --chef-license accept -L /var/log/chef/client.log")
+ expect(provider.cron_command).to eql(
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} --chef-license accept -L /var/log/chef/client.log"
+ )
end
end
end
diff --git a/spec/unit/resource/chef_client_systemd_timer_spec.rb b/spec/unit/resource/chef_client_systemd_timer_spec.rb
index b175bb27ec..1866060530 100644
--- a/spec/unit/resource/chef_client_systemd_timer_spec.rb
+++ b/spec/unit/resource/chef_client_systemd_timer_spec.rb
@@ -43,13 +43,16 @@ describe Chef::Resource::ChefClientSystemdTimer do
end
describe "#chef_client_cmd" do
+
+ let(:root_path) { windows? ? "C:\\chef/client.rb" : "/etc/chef/client.rb" }
+
it "creates a valid command if using all default properties" do
- expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client -c /etc/chef/client.rb")
+ expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client -c #{root_path}")
end
it "uses daemon_options if set" do
resource.daemon_options ["--foo 1", "--bar 2"]
- expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client --foo 1 --bar 2 -c /etc/chef/client.rb")
+ expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client --foo 1 --bar 2 -c #{root_path}")
end
it "uses custom config dir if set" do
@@ -59,12 +62,12 @@ describe Chef::Resource::ChefClientSystemdTimer do
it "uses custom chef-client binary if set" do
resource.chef_binary_path "/usr/local/bin/chef-client"
- expect(provider.chef_client_cmd).to eql("/usr/local/bin/chef-client -c /etc/chef/client.rb")
+ expect(provider.chef_client_cmd).to eql("/usr/local/bin/chef-client -c #{root_path}")
end
it "sets the license acceptance flag if set" do
resource.accept_chef_license true
- expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client --chef-license accept -c /etc/chef/client.rb")
+ expect(provider.chef_client_cmd).to eql("/opt/chef/bin/chef-client --chef-license accept -c #{root_path}")
end
end
end
diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb
index d0e697a1cd..d1fe863891 100644
--- a/spec/unit/resource/file/verification_spec.rb
+++ b/spec/unit/resource/file/verification_spec.rb
@@ -112,7 +112,8 @@ describe Chef::Resource::File::Verification do
end
it "returns true if the command succeeds" do
- v = Chef::Resource::File::Verification.new(parent_resource, "true", {})
+ test_command = platform_specific_verify_command("path")
+ v = Chef::Resource::File::Verification.new(parent_resource, test_command, {})
expect(v.verify(temp_path)).to eq(true)
end