summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/event_loggers/windows_eventlog_spec.rb2
-rw-r--r--spec/functional/mixin/user_context_spec.rb4
-rw-r--r--spec/functional/rebooter_spec.rb2
-rw-r--r--spec/functional/resource/cookbook_file_spec.rb4
-rw-r--r--spec/functional/resource/template_spec.rb2
-rw-r--r--spec/functional/win32/crypto_spec.rb2
-rw-r--r--spec/functional/win32/security_spec.rb2
-rw-r--r--spec/functional/win32/service_manager_spec.rb2
-rw-r--r--spec/functional/win32/sid_spec.rb4
-rw-r--r--spec/functional/win32/version_info_spec.rb2
-rw-r--r--spec/functional/win32/versions_spec.rb2
-rw-r--r--spec/integration/client/client_spec.rb2
-rw-r--r--spec/integration/knife/config_get_profile_spec.rb4
-rw-r--r--spec/integration/knife/config_get_spec.rb4
-rw-r--r--spec/integration/knife/config_list_profiles_spec.rb4
-rw-r--r--spec/integration/knife/config_use_profile_spec.rb4
-rw-r--r--spec/integration/knife/list_spec.rb4
-rw-r--r--spec/integration/solo/solo_spec.rb2
-rw-r--r--spec/support/matchers/leak.rb2
-rw-r--r--spec/support/mock/platform.rb2
-rw-r--r--spec/support/platform_helpers.rb2
-rw-r--r--spec/support/shared/integration/integration_helper.rb2
-rw-r--r--spec/support/shared/integration/knife_support.rb2
-rw-r--r--spec/support/shared/unit/provider/file.rb8
-rw-r--r--spec/unit/application/client_spec.rb4
-rw-r--r--spec/unit/application_spec.rb2
-rw-r--r--spec/unit/chef_fs/file_pattern_spec.rb4
-rw-r--r--spec/unit/chef_fs/path_util_spec.rb6
-rw-r--r--spec/unit/client_spec.rb6
-rw-r--r--spec/unit/cookbook/cookbook_version_loader_spec.rb4
-rw-r--r--spec/unit/cookbook/syntax_check_spec.rb4
-rw-r--r--spec/unit/cookbook_loader_spec.rb2
-rw-r--r--spec/unit/data_bag_spec.rb4
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb32
-rw-r--r--spec/unit/file_content_management/deploy/mv_windows_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb2
-rw-r--r--spec/unit/knife/bootstrap_spec.rb2
-rw-r--r--spec/unit/knife/core/gem_glob_loader_spec.rb2
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb2
-rw-r--r--spec/unit/knife/core/subcommand_loader_spec.rb2
-rw-r--r--spec/unit/knife/core/ui_spec.rb4
-rw-r--r--spec/unit/knife/data_bag_from_file_spec.rb4
-rw-r--r--spec/unit/knife/environment_from_file_spec.rb4
-rw-r--r--spec/unit/knife/supermarket_install_spec.rb2
-rw-r--r--spec/unit/mixin/path_sanity_spec.rb6
-rw-r--r--spec/unit/mixin/shell_out_spec.rb2
-rw-r--r--spec/unit/mixin/template_spec.rb8
-rw-r--r--spec/unit/mixin/user_context_spec.rb6
-rw-r--r--spec/unit/node_map_spec.rb24
-rw-r--r--spec/unit/platform/query_helpers_spec.rb18
-rw-r--r--spec/unit/provider/execute_spec.rb2
-rw-r--r--spec/unit/provider/link_spec.rb10
-rw-r--r--spec/unit/provider/package/windows/exe_spec.rb2
-rw-r--r--spec/unit/provider/package/windows_spec.rb4
-rw-r--r--spec/unit/provider/remote_file/fetcher_spec.rb4
-rw-r--r--spec/unit/provider/remote_file/local_file_spec.rb2
-rw-r--r--spec/unit/provider/remote_file/network_file_spec.rb2
-rw-r--r--spec/unit/provider/script_spec.rb4
-rw-r--r--spec/unit/provider/subversion_spec.rb6
-rw-r--r--spec/unit/provider/user/dscl_spec.rb4
-rw-r--r--spec/unit/provider_resolver_spec.rb103
-rw-r--r--spec/unit/resource/cookbook_file_spec.rb6
-rw-r--r--spec/unit/resource/remote_file_spec.rb6
-rw-r--r--spec/unit/role_spec.rb4
-rw-r--r--spec/unit/shell_spec.rb2
-rw-r--r--spec/unit/win32/error_spec.rb2
-rw-r--r--spec/unit/win32/link_spec.rb2
-rw-r--r--spec/unit/win32/security_spec.rb2
-rw-r--r--spec/unit/windows_service_spec.rb2
69 files changed, 203 insertions, 194 deletions
diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb
index 8a9475680d..06aac89c6a 100644
--- a/spec/functional/event_loggers/windows_eventlog_spec.rb
+++ b/spec/functional/event_loggers/windows_eventlog_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
require "securerandom"
require "chef/event_loggers/windows_eventlog"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "win32/eventlog"
include Win32
end
diff --git a/spec/functional/mixin/user_context_spec.rb b/spec/functional/mixin/user_context_spec.rb
index 802b1db9f1..909555d997 100644
--- a/spec/functional/mixin/user_context_spec.rb
+++ b/spec/functional/mixin/user_context_spec.rb
@@ -17,8 +17,8 @@
require "spec_helper"
-require "chef/win32/api" if Chef::Platform.windows?
-require "chef/win32/api/error" if Chef::Platform.windows?
+require "chef/win32/api" if ChefHelpers.windows?
+require "chef/win32/api/error" if ChefHelpers.windows?
require "chef/mixin/user_context"
describe Chef::Mixin::UserContext, windows_only: true do
diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb
index 8e5b23f86b..1e2c2ab2b8 100644
--- a/spec/functional/rebooter_spec.rb
+++ b/spec/functional/rebooter_spec.rb
@@ -72,7 +72,7 @@ describe Chef::Platform::Rebooter do
shared_context "test a reboot method" do
def test_rebooter_method(method_sym, is_windows, is_solaris, expected_reboot_str)
- allow(ChefConfig).to receive(:windows?).and_return(is_windows)
+ allow(ChefHelpers).to receive(:windows?).and_return(is_windows)
node.automatic["os"] = node.automatic["platform"] = node.automatic["platform_family"] = "solaris2" if is_solaris
expect(rebooter).to receive(:shell_out!).once.with(expected_reboot_str)
expect(rebooter).to receive(:raise).with(Chef::Exceptions::Reboot)
diff --git a/spec/functional/resource/cookbook_file_spec.rb b/spec/functional/resource/cookbook_file_spec.rb
index d127413c73..826c5ac094 100644
--- a/spec/functional/resource/cookbook_file_spec.rb
+++ b/spec/functional/resource/cookbook_file_spec.rb
@@ -70,11 +70,11 @@ describe Chef::Resource::CookbookFile do
let(:path) { File.join(windows_non_temp_dir, make_tmpname(file_base)) }
before do
- FileUtils.mkdir_p(windows_non_temp_dir) if Chef::Platform.windows?
+ FileUtils.mkdir_p(windows_non_temp_dir) if ChefHelpers.windows?
end
after do
- FileUtils.rm_r(windows_non_temp_dir) if Chef::Platform.windows? && File.exists?(windows_non_temp_dir)
+ FileUtils.rm_r(windows_non_temp_dir) if ChefHelpers.windows? && File.exists?(windows_non_temp_dir)
end
end
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index 679ffe661a..5d66c13ab8 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -203,7 +203,7 @@ describe Chef::Resource::Template do
it "output should contain platform's line endings" do
resource.run_action(:create)
binread(path).each_line do |line|
- expect(line).to end_with(Chef::Platform.windows? ? "\r\n" : "\n")
+ expect(line).to end_with(ChefHelpers.windows? ? "\r\n" : "\n")
end
end
end
diff --git a/spec/functional/win32/crypto_spec.rb b/spec/functional/win32/crypto_spec.rb
index 5fcbca02b6..634151799a 100644
--- a/spec/functional/win32/crypto_spec.rb
+++ b/spec/functional/win32/crypto_spec.rb
@@ -17,7 +17,7 @@
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/crypto"
end
diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb
index b3fe2afb31..8a43ea762f 100644
--- a/spec/functional/win32/security_spec.rb
+++ b/spec/functional/win32/security_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
require "mixlib/shellout"
require "chef/mixin/user_context"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/security"
end
diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb
index 8fff73396e..79d656ce46 100644
--- a/spec/functional/win32/service_manager_spec.rb
+++ b/spec/functional/win32/service_manager_spec.rb
@@ -17,7 +17,7 @@
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/application/windows_service_manager"
end
diff --git a/spec/functional/win32/sid_spec.rb b/spec/functional/win32/sid_spec.rb
index eac62d88b6..847336b596 100644
--- a/spec/functional/win32/sid_spec.rb
+++ b/spec/functional/win32/sid_spec.rb
@@ -17,12 +17,12 @@
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/security"
end
describe "Chef::ReservedNames::Win32::SID", :windows_only do
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
SID ||= Chef::ReservedNames::Win32::Security::SID
end
diff --git a/spec/functional/win32/version_info_spec.rb b/spec/functional/win32/version_info_spec.rb
index b5570732a0..2de70f6c56 100644
--- a/spec/functional/win32/version_info_spec.rb
+++ b/spec/functional/win32/version_info_spec.rb
@@ -17,7 +17,7 @@
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/file/version_info"
end
diff --git a/spec/functional/win32/versions_spec.rb b/spec/functional/win32/versions_spec.rb
index 19bd0e3875..b5097cef20 100644
--- a/spec/functional/win32/versions_spec.rb
+++ b/spec/functional/win32/versions_spec.rb
@@ -17,7 +17,7 @@
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/version"
end
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index 4408c00b23..fb71396d1a 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -62,7 +62,7 @@ EOM
shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", cwd: chef_dir)
end
- it "should complete successfully with no other environment variables", skip: (Chef::Platform.windows?) do
+ it "should complete successfully with no other environment variables", skip: (ChefHelpers.windows?) do
file "config/client.rb", <<~EOM
local_mode true
cookbook_path "#{path_to('cookbooks')}"
diff --git a/spec/integration/knife/config_get_profile_spec.rb b/spec/integration/knife/config_get_profile_spec.rb
index e97b24b869..1ead66d2dd 100644
--- a/spec/integration/knife/config_get_profile_spec.rb
+++ b/spec/integration/knife/config_get_profile_spec.rb
@@ -50,7 +50,7 @@ describe "knife config get-profile", :workstation do
ENV["KNIFE_HOME"] = old_knife_home
ENV["HOME"] = old_home
Dir.chdir(old_wd)
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV[ChefHelpers.windows? ? "CD" : "PWD"] = Dir.pwd
ChefConfig::PathHelper.per_tool_home_environment = nil
end
end
@@ -60,7 +60,7 @@ describe "knife config get-profile", :workstation do
# because it has to run after the before set in the "with a chef repo" shared context.
directory("repo")
Dir.chdir(path_to("repo"))
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV[ChefHelpers.windows? ? "CD" : "PWD"] = Dir.pwd
ENV["HOME"] = path_to(".")
end
diff --git a/spec/integration/knife/config_get_spec.rb b/spec/integration/knife/config_get_spec.rb
index f34d096051..c18b9156b0 100644
--- a/spec/integration/knife/config_get_spec.rb
+++ b/spec/integration/knife/config_get_spec.rb
@@ -54,7 +54,7 @@ describe "knife config get", :workstation do
ENV["KNIFE_HOME"] = old_knife_home
ENV["HOME"] = old_home
Dir.chdir(old_wd)
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV[ChefHelpers.windows? ? "CD" : "PWD"] = Dir.pwd
ChefConfig::PathHelper.per_tool_home_environment = nil
end
end
@@ -64,7 +64,7 @@ describe "knife config get", :workstation do
# because it has to run after the before set in the "with a chef repo" shared context.
directory("repo")
Dir.chdir(path_to("repo"))
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV[ChefHelpers.windows? ? "CD" : "PWD"] = Dir.pwd
ENV["HOME"] = path_to(".")
end
diff --git a/spec/integration/knife/config_list_profiles_spec.rb b/spec/integration/knife/config_list_profiles_spec.rb
index 32846f9999..b8a20c9e3b 100644
--- a/spec/integration/knife/config_list_profiles_spec.rb
+++ b/spec/integration/knife/config_list_profiles_spec.rb
@@ -44,7 +44,7 @@ describe "knife config list-profiles", :workstation do
ensure
ENV["HOME"] = old_home
Dir.chdir(old_wd)
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV[ChefHelpers.windows? ? "CD" : "PWD"] = Dir.pwd
end
end
@@ -53,7 +53,7 @@ describe "knife config list-profiles", :workstation do
# because it has to run after the before set in the "with a chef repo" shared context.
directory("repo")
Dir.chdir(path_to("repo"))
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV[ChefHelpers.windows? ? "CD" : "PWD"] = Dir.pwd
ENV["HOME"] = path_to(".")
end
diff --git a/spec/integration/knife/config_use_profile_spec.rb b/spec/integration/knife/config_use_profile_spec.rb
index a021dbbe6f..caf1e8b3da 100644
--- a/spec/integration/knife/config_use_profile_spec.rb
+++ b/spec/integration/knife/config_use_profile_spec.rb
@@ -51,7 +51,7 @@ describe "knife config use-profile", :workstation do
ENV["KNIFE_HOME"] = old_knife_home
ENV["HOME"] = old_home
Dir.chdir(old_wd)
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV[ChefHelpers.windows? ? "CD" : "PWD"] = Dir.pwd
ChefConfig::PathHelper.per_tool_home_environment = nil
end
end
@@ -61,7 +61,7 @@ describe "knife config use-profile", :workstation do
# because it has to run after the before set in the "with a chef repo" shared context.
directory("repo")
Dir.chdir(path_to("repo"))
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
+ ENV[ChefHelpers.windows? ? "CD" : "PWD"] = Dir.pwd
ENV["HOME"] = path_to(".")
end
diff --git a/spec/integration/knife/list_spec.rb b/spec/integration/knife/list_spec.rb
index 39a3f77fc5..0eaff01b00 100644
--- a/spec/integration/knife/list_spec.rb
+++ b/spec/integration/knife/list_spec.rb
@@ -466,7 +466,7 @@ EOM
end
end
- when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", skip: (Chef::Platform.windows?) do
+ when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", skip: (ChefHelpers.windows?) do
before do
directory "cookbooks"
symlink "symlinked", "cookbooks"
@@ -503,7 +503,7 @@ EOM
end
end
- when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", skip: (Chef::Platform.windows?) do
+ when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", skip: (ChefHelpers.windows?) do
before do
directory "real_cookbooks"
symlink "cookbooks", "real_cookbooks"
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 58314473e7..7964d37f9c 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -4,7 +4,7 @@ require "chef/run_lock"
require "chef/config"
require "timeout"
require "fileutils"
-require "chef/win32/security" if Chef::Platform.windows?
+require "chef/win32/security" if ChefHelpers.windows?
describe "chef-solo" do
include IntegrationSupport
diff --git a/spec/support/matchers/leak.rb b/spec/support/matchers/leak.rb
index 5f22c1c151..4c6ca66d06 100644
--- a/spec/support/matchers/leak.rb
+++ b/spec/support/matchers/leak.rb
@@ -60,7 +60,7 @@ module Matchers
def profiler
@profiler ||= begin
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
require File.join(File.dirname(__FILE__), "..", "platforms", "prof", "win32")
RSpec::Prof::Win32::Profiler.new
else
diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb
index c6670827f9..1795c5a7ba 100644
--- a/spec/support/mock/platform.rb
+++ b/spec/support/mock/platform.rb
@@ -6,7 +6,7 @@
# testing code that mixes in platform specific modules like +Chef::Mixin::Securable+
# or +Chef::FileAccessControl+
def platform_mock(platform = :unix)
- allow(ChefConfig).to receive(:windows?).and_return(platform == :windows ? true : false)
+ allow(ChefHelpers).to receive(:windows?).and_return(platform == :windows ? true : false)
ENV["SYSTEMDRIVE"] = (platform == :windows ? "C:" : nil)
if platform == :windows
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 6ae052ba1d..b930002710 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -34,6 +34,8 @@ def ruby_32bit?
end
def windows?
+ # NOTE this deliberately does not use ChefHelpers.windows? because otherwise it would
+ # pick up the node out of tests, while this tests the hosts running the specs.
!!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
end
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index 5fc9de4de7..e2019306b2 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -128,7 +128,7 @@ module IntegrationSupport
# TODO: "force" actually means "silence all exceptions". this
# silences a weird permissions error on Windows that we should track
# down, but for now there's no reason for it to blow up our CI.
- FileUtils.remove_entry_secure(@repository_dir, force = Chef::Platform.windows?)
+ FileUtils.remove_entry_secure(@repository_dir, force = ChefHelpers.windows?)
ensure
@repository_dir = nil
end
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb
index 87ce1bc0b0..37ca78ba46 100644
--- a/spec/support/shared/integration/knife_support.rb
+++ b/spec/support/shared/integration/knife_support.rb
@@ -181,7 +181,7 @@ module KnifeSupport
expect(stderr_actual).to eq(expected[:stderr])
end
stdout_actual = @stdout
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
stderr_actual = stderr_actual.gsub("\r\n", "\n")
stdout_actual = stdout_actual.gsub("\r\n", "\n")
end
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index a7c7af92f6..482a22b952 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -1,6 +1,6 @@
#
# Author:: Lamont Granquist (<lamont@chef.io>)
-# Copyright:: Copyright 2013-2016, Chef Software, Inc.
+# Copyright:: Copyright 2013-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -255,7 +255,7 @@ shared_examples_for Chef::Provider::File do
context "examining file security metadata on Unix with a file that exists" do
before do
# fake that we're on unix even if we're on windows
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
# mock up the filesystem to behave like unix
setup_normal_file
stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
@@ -331,7 +331,7 @@ shared_examples_for Chef::Provider::File do
context "examining file security metadata on Unix with a file that does not exist" do
before do
# fake that we're on unix even if we're on windows
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
setup_missing_file
end
@@ -380,7 +380,7 @@ shared_examples_for Chef::Provider::File do
before do
# fake that we're on unix even if we're on windows
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
# mock up the filesystem to behave like unix
setup_normal_file
stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 40f690abb1..d57205ba28 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -219,7 +219,7 @@ describe Chef::Application::Client, "reconfigure" do
it "should terminal with message when interval is given" do
Chef::Config[:interval] = 600
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
expect(Chef::Application).to receive(:fatal!).with(
"Unforked chef-client interval runs are disabled in Chef 12.
Configuration settings:
@@ -232,7 +232,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
context "when interval is given on windows" do
before do
Chef::Config[:interval] = 600
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
end
it "should not terminate" do
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index b8d7242466..423b7da1dd 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -270,7 +270,7 @@ describe Chef::Application do
end
end
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
it_behaves_like "sets log_location", :win_evt, Chef::Log::WinEvt
it_behaves_like "sets log_location", "win_evt", Chef::Log::WinEvt
else
diff --git a/spec/unit/chef_fs/file_pattern_spec.rb b/spec/unit/chef_fs/file_pattern_spec.rb
index 58cdbb28c2..a06468c1e2 100644
--- a/spec/unit/chef_fs/file_pattern_spec.rb
+++ b/spec/unit/chef_fs/file_pattern_spec.rb
@@ -157,7 +157,7 @@ describe Chef::ChefFS::FilePattern do
end
end
- context 'with simple pattern "a\*\b"', skip: (Chef::Platform.windows?) do
+ context 'with simple pattern "a\*\b"', skip: (ChefHelpers.windows?) do
let(:pattern) { Chef::ChefFS::FilePattern.new('a\*\b') }
it "match?" do
expect(pattern.match?("a*b")).to be_truthy
@@ -264,7 +264,7 @@ describe Chef::ChefFS::FilePattern do
end
end
- context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', skip: (Chef::Platform.windows?) do
+ context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', skip: (ChefHelpers.windows?) do
let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d[a-z][0-9]f/ghi") }
it "match?" do
expect(pattern.match?("/abc/de1f/ghi")).to be_truthy
diff --git a/spec/unit/chef_fs/path_util_spec.rb b/spec/unit/chef_fs/path_util_spec.rb
index 93205a1815..1140fe6054 100644
--- a/spec/unit/chef_fs/path_util_spec.rb
+++ b/spec/unit/chef_fs/path_util_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Kartik Null Cating-Subramanian (<ksubramanian@chef.io>)
-# Copyright:: Copyright 2015-2016, Chef Software Inc.
+# Copyright:: Copyright 2015-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -81,7 +81,7 @@ describe Chef::ChefFS::PathUtils do
end
it "handles root correctly" do
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
expect(Chef::ChefFS::PathUtils.realest_path("C:/")).to eq("C:/")
else
expect(Chef::ChefFS::PathUtils.realest_path("/")).to eq("/")
@@ -91,7 +91,7 @@ describe Chef::ChefFS::PathUtils do
context "invoking descendant_path" do
it "handles paths with various casing on windows" do
- allow(Chef::ChefFS).to receive(:windows?) { true }
+ allow(ChefHelpers).to receive(:windows?) { true }
expect(Chef::ChefFS::PathUtils.descendant_path("C:/ab/b/c", "C:/AB/B")).to eq("c")
expect(Chef::ChefFS::PathUtils.descendant_path("C:/ab/b/c", "c:/ab/B")).to eq("c")
end
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index 4f9d66d776..ec291e670f 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Tim Hinderliter (<tim@chef.io>)
# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -457,7 +457,7 @@ EOM
describe "windows_admin_check" do
context "platform is not windows" do
before do
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
end
it "shouldn't be called" do
@@ -468,7 +468,7 @@ EOM
context "platform is windows" do
before do
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
end
it "should be called" do
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb
index 40a054abee..993d414c9c 100644
--- a/spec/unit/cookbook/cookbook_version_loader_spec.rb
+++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::Cookbook::CookbookVersionLoader do
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
end
describe "loading a cookbook" do
diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb
index a24fa3ab2a..da45311b4e 100644
--- a/spec/unit/cookbook/syntax_check_spec.rb
+++ b/spec/unit/cookbook/syntax_check_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@ require "chef/cookbook/syntax_check"
describe Chef::Cookbook::SyntaxCheck do
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
end
let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "cookbooks", "openldap") }
diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb
index 6553dad433..73e539d746 100644
--- a/spec/unit/cookbook_loader_spec.rb
+++ b/spec/unit/cookbook_loader_spec.rb
@@ -20,7 +20,7 @@ require "spec_helper"
describe Chef::CookbookLoader do
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
end
let(:repo_paths) do
[
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index f20148de72..66854fd23b 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@ require "chef/data_bag"
describe Chef::DataBag do
before(:each) do
@data_bag = Chef::DataBag.new
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
end
describe "initialize" do
diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb
index 51123ba930..fb8e2a219e 100644
--- a/spec/unit/dsl/platform_introspection_spec.rb
+++ b/spec/unit/dsl/platform_introspection_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Seth Falcon (<seth@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -127,3 +127,33 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
end
end
+
+describe "ChefHelper functions mixed into classes" do
+ METHODS = [ :windows?, :fedora_derived?, :bsd_based?, :rhel?, :aix?, :gentoo? ]
+
+ METHODS.each do |method|
+ it "mixes #{method} into Chef::Resource instances" do
+ expect(Chef::Resource.instance_methods.include?(method)).to be true
+ end
+
+ it "mixes #{method} into Chef::Resource classes (provides lines, etc)" do
+ expect(Chef::Resource.respond_to?(method)).to be true
+ end
+
+ it "mixes #{method} into Chef::Provider instances (actions)" do
+ expect(Chef::Provider.instance_methods.include?(method)).to be true
+ end
+
+ it "mixes #{method} into Chef::Provider classes (provides lines, etc)" do
+ expect(Chef::Provider.respond_to?(method)).to be true
+ end
+
+ it "mixes #{method} into Chef::Recipe instances (recipe files)" do
+ expect(Chef::Recipe.instance_methods.include?(method)).to be true
+ end
+
+ it "mixes #{method} into Chef::Node instances (attribute files)" do
+ expect(Chef::Recipe.instance_methods.include?(method)).to be true
+ end
+ end
+end
diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb
index 80155f131c..25046dc91d 100644
--- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb
@@ -18,7 +18,7 @@
require "spec_helper"
-unless Chef::Platform.windows?
+unless ChefHelpers.windows?
class Chef
module ReservedNames
module Win32
diff --git a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
index 209d987e78..22ff5515f0 100644
--- a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 624261fb8b..8dbf5060c2 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -23,7 +23,7 @@ require "net/ssh"
describe Chef::Knife::Bootstrap do
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
end
let(:knife) do
Chef::Log.logger = Logger.new(StringIO.new)
diff --git a/spec/unit/knife/core/gem_glob_loader_spec.rb b/spec/unit/knife/core/gem_glob_loader_spec.rb
index 689426de1b..56a212f846 100644
--- a/spec/unit/knife/core/gem_glob_loader_spec.rb
+++ b/spec/unit/knife/core/gem_glob_loader_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") }
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
Chef::Util::PathHelper.class_variable_set(:@@home_dir, home)
end
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index e866f13a9c..2a1959c394 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -19,7 +19,7 @@ require "spec_helper"
describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
end
let(:plugin_manifest) do
diff --git a/spec/unit/knife/core/subcommand_loader_spec.rb b/spec/unit/knife/core/subcommand_loader_spec.rb
index 5db0bb73e5..40b3fc3caf 100644
--- a/spec/unit/knife/core/subcommand_loader_spec.rb
+++ b/spec/unit/knife/core/subcommand_loader_spec.rb
@@ -23,7 +23,7 @@ describe Chef::Knife::SubcommandLoader do
let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") }
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
Chef::Util::PathHelper.class_variable_set(:@@home_dir, home)
end
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index 025c1ecd91..bf0a3d1534 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -3,7 +3,7 @@
# Author:: Tim Hinderliter (<tim@chef.io>)
# Author:: Daniel DeLeo (<dan@chef.io>)
# Author:: John Keiser (<jkeiser@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -482,7 +482,7 @@ EOM
before(:each) do
stdout = double("StringIO", tty?: true)
allow(@ui).to receive(:stdout).and_return(stdout)
- allow(ChefConfig).to receive(:windows?) { true }
+ allow(ChefHelpers).to receive(:windows?) { true }
Chef::Config.reset
end
diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb
index 3bea392ae2..373a110f57 100644
--- a/spec/unit/knife/data_bag_from_file_spec.rb
+++ b/spec/unit/knife/data_bag_from_file_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Seth Falcon (<seth@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,7 +26,7 @@ Chef::Knife::DataBagFromFile.load_deps
describe Chef::Knife::DataBagFromFile do
before :each do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
Chef::Config[:node_name] = "webmonkey.example.com"
FileUtils.mkdir_p([db_folder, db_folder2])
db_file.write(Chef::JSONCompat.to_json(plain_data))
diff --git a/spec/unit/knife/environment_from_file_spec.rb b/spec/unit/knife/environment_from_file_spec.rb
index 11e05cb922..17cc5b2ba4 100644
--- a/spec/unit/knife/environment_from_file_spec.rb
+++ b/spec/unit/knife/environment_from_file_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: Stephen Delano (<stephen@ospcode.com>)
# Author:: Seth Falcon (<seth@ospcode.com>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,7 @@ Chef::Knife::EnvironmentFromFile.load_deps
describe Chef::Knife::EnvironmentFromFile do
before(:each) do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
@knife = Chef::Knife::EnvironmentFromFile.new
@stdout = StringIO.new
allow(@knife.ui).to receive(:stdout).and_return(@stdout)
diff --git a/spec/unit/knife/supermarket_install_spec.rb b/spec/unit/knife/supermarket_install_spec.rb
index 68c8af1028..bb33bea516 100644
--- a/spec/unit/knife/supermarket_install_spec.rb
+++ b/spec/unit/knife/supermarket_install_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Knife::SupermarketInstall do
prepare_to_import: true, finalize_updates_to: true,
merge_updates_from: true) end
let(:install_path) do
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
"C:/tmp/chef"
else
"/var/tmp/chef"
diff --git a/spec/unit/mixin/path_sanity_spec.rb b/spec/unit/mixin/path_sanity_spec.rb
index c9ed4e2595..417a5c74bd 100644
--- a/spec/unit/mixin/path_sanity_spec.rb
+++ b/spec/unit/mixin/path_sanity_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Seth Chisamore (<schisamo@chef.io>)
-# Copyright:: Copyright 2011-2017, Chef Software Inc.
+# Copyright:: Copyright 2011-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,7 +35,7 @@ describe Chef::Mixin::PathSanity do
@gem_bindir = "/some/gem/bin"
allow(Gem).to receive(:bindir).and_return(@gem_bindir)
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(@ruby_bindir)
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
end
it "adds all useful PATHs even if environment is an empty hash" do
@@ -83,7 +83,7 @@ describe Chef::Mixin::PathSanity do
gem_bindir = 'C:\gems\bin'
allow(Gem).to receive(:bindir).and_return(gem_bindir)
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir)
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
env = { "PATH" => 'C:\Windows\system32;C:\mr\softie' }
@sanity.enforce_path_sanity(env)
expect(env["PATH"]).to eq("#{gem_bindir};#{ruby_bindir};C:\\Windows\\system32;C:\\mr\\softie")
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 7f6021d911..9c10813eb0 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -30,7 +30,7 @@ describe Chef::Mixin::ShellOut do
subject(:shell_out_obj) { shell_out_class.new }
def env_path
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
"Path"
else
"PATH"
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb
index ab7ed5bc5a..bd50afdaf9 100644
--- a/spec/unit/mixin/template_spec.rb
+++ b/spec/unit/mixin/template_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@ require "spec_helper"
require "cgi"
describe Chef::Mixin::Template, "render_template" do
- let(:sep) { Chef::Platform.windows? ? "\r\n" : "\n" }
+ let(:sep) { ChefHelpers.windows? ? "\r\n" : "\n" }
before :each do
@context = Chef::Mixin::Template::TemplateContext.new({})
@@ -39,7 +39,7 @@ describe Chef::Mixin::Template, "render_template" do
describe "when running on windows" do
before do
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
end
it "should render the templates with windows line endings" do
@@ -54,7 +54,7 @@ describe Chef::Mixin::Template, "render_template" do
describe "when running on unix" do
before do
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
end
it "should render the templates with unix line endings" do
diff --git a/spec/unit/mixin/user_context_spec.rb b/spec/unit/mixin/user_context_spec.rb
index 896241f173..2271d80990 100644
--- a/spec/unit/mixin/user_context_spec.rb
+++ b/spec/unit/mixin/user_context_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Edwards (<adamed@chef.io>)
-# Copyright:: Copyright (c) 2015 Chef Software, Inc.
+# Copyright:: Copyright (c) 2015-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,7 +39,7 @@ describe "a class that mixes in user_context" do
context "when running on Windows" do
before do
- allow(::Chef::Platform).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
allow(::Chef::Util::Windows::LogonSession).to receive(:new).and_return(logon_session)
end
@@ -98,7 +98,7 @@ describe "a class that mixes in user_context" do
context "when not running on Windows" do
before do
- allow(::Chef::Platform).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
end
it "raises a ::Chef::Exceptions::UnsupportedPlatform exception" do
diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb
index df70ad380a..c2dfe518d0 100644
--- a/spec/unit/node_map_spec.rb
+++ b/spec/unit/node_map_spec.rb
@@ -104,8 +104,8 @@ describe Chef::NodeMap do
end
it "returns nil when the platform_family does not match" do
- allow(node).to receive(:[]).with(:os).and_return("linux")
- allow(node).to receive(:[]).with(:platform_family).and_return("debian")
+ node.automatic["os"] = "linux"
+ node.automatic["platform_family"] = "debian"
expect(node_map.get(node, :thing)).to eql(nil)
end
end
@@ -174,26 +174,26 @@ describe Chef::NodeMap do
end
it "returns the value when the node matches" do
- allow(node).to receive(:[]).with(:platform_family).and_return("rhel")
- allow(node).to receive(:[]).with(:platform_version).and_return("7.0")
+ node.automatic["platform_family"] = "rhel"
+ node.automatic["platform_version"] = "7.0"
expect(node_map.get(node, :thing)).to eql(:foo)
end
it "returns nil when the block does not match" do
- allow(node).to receive(:[]).with(:platform_family).and_return("rhel")
- allow(node).to receive(:[]).with(:platform_version).and_return("6.4")
+ node.automatic["platform_family"] = "rhel"
+ node.automatic["platform_version"] = "6.4"
expect(node_map.get(node, :thing)).to eql(nil)
end
it "returns nil when the platform_family filter does not match" do
- allow(node).to receive(:[]).with(:platform_family).and_return("debian")
- allow(node).to receive(:[]).with(:platform_version).and_return("7.0")
+ node.automatic["platform_family"] = "debian"
+ node.automatic["platform_version"] = "7.0"
expect(node_map.get(node, :thing)).to eql(nil)
end
it "returns nil when both do not match" do
- allow(node).to receive(:[]).with(:platform_family).and_return("debian")
- allow(node).to receive(:[]).with(:platform_version).and_return("6.0")
+ node.automatic["platform_family"] = "debian"
+ node.automatic["platform_version"] = "6.0"
expect(node_map.get(node, :thing)).to eql(nil)
end
@@ -203,8 +203,8 @@ describe Chef::NodeMap do
end
it "returns the value when the node matches" do
- allow(node).to receive(:[]).with(:platform_family).and_return("rhel")
- allow(node).to receive(:[]).with(:platform_version).and_return("7.0")
+ node.automatic["platform_family"] = "rhel"
+ node.automatic["platform_version"] = "7.0"
expect(node_map.get(node, :thing)).to eql(:foo)
end
end
diff --git a/spec/unit/platform/query_helpers_spec.rb b/spec/unit/platform/query_helpers_spec.rb
index 82ed4de9c6..e6e155c0d8 100644
--- a/spec/unit/platform/query_helpers_spec.rb
+++ b/spec/unit/platform/query_helpers_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,13 +43,13 @@ describe "Chef::Platform#windows_nano_server?" do
end
it "returns false early when not on windows" do
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
expect(Chef::Platform).to_not receive(:require)
expect(Chef::Platform.windows_nano_server?).to be false
end
it "returns true when the registry value is 1" do
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
.with(key, access)
@@ -59,7 +59,7 @@ describe "Chef::Platform#windows_nano_server?" do
end
it "returns false when the registry value is not 1" do
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
.with(key, access)
@@ -69,7 +69,7 @@ describe "Chef::Platform#windows_nano_server?" do
end
it "returns false when the registry value does not exist" do
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
.with(key, access)
@@ -80,7 +80,7 @@ describe "Chef::Platform#windows_nano_server?" do
end
it "returns false when the registry key does not exist" do
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
.with(key, access)
@@ -114,13 +114,13 @@ describe "Chef::Platform#supports_msi?" do
end
it "returns false early when not on windows" do
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
expect(Chef::Platform).to_not receive(:require)
expect(Chef::Platform.supports_msi?).to be false
end
it "returns true when the registry key exists" do
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
.with(key, access)
@@ -129,7 +129,7 @@ describe "Chef::Platform#supports_msi?" do
end
it "returns false when the registry key does not exist" do
- allow(ChefConfig).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
allow(Chef::Platform).to receive(:require).with("win32/registry")
expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open)
.with(key, access)
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 9718a012da..42685883fc 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -42,7 +42,7 @@ describe Chef::Provider::Execute do
before do
allow(Chef::EventDispatch::EventsOutputStream).to receive(:new) { @live_stream }
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
@original_log_level = Chef::Log.level
Chef::Log.level = :info
allow(STDOUT).to receive(:tty?).and_return(false)
diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb
index 027b318c7e..5cb0250c7e 100644
--- a/spec/unit/provider/link_spec.rb
+++ b/spec/unit/provider/link_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
# Author:: John Keiser (<jkeiser@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@ require "ostruct"
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/file" # probably need this in spec_helper
end
@@ -41,7 +41,7 @@ describe Chef::Resource::Link do
end
def canonicalize(path)
- Chef::Platform.windows? ? path.tr("/", '\\') : path
+ ChefHelpers.windows? ? path.tr("/", '\\') : path
end
describe "when the target is a symlink" do
@@ -348,7 +348,7 @@ describe Chef::Resource::Link do
allow(Chef::Resource::Link).to receive(:new).with(
provider.new_resource.name).and_return(resource_link)
allow(resource_link).to receive(:verify_links_supported!)
- allow(Chef::Platform).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
end
context "soft links" do
@@ -378,7 +378,7 @@ describe Chef::Resource::Link do
context "on Linux platform" do
before(:each) do
- allow(Chef::Platform).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
end
context "soft links" do
diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb
index 4f6a6121bd..7c525d771c 100644
--- a/spec/unit/provider/package/windows/exe_spec.rb
+++ b/spec/unit/provider/package/windows/exe_spec.rb
@@ -19,7 +19,7 @@
require "spec_helper"
require "chef/provider/package/windows/exe"
-unless Chef::Platform.windows?
+unless ChefHelpers.windows?
class Chef
module ReservedNames::Win32
class File
diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb
index 6b85013f3d..3062a475f1 100644
--- a/spec/unit/provider/package/windows_spec.rb
+++ b/spec/unit/provider/package/windows_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2014-2017, Chef Software Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@ require "chef/provider/package/windows/msi"
describe Chef::Provider::Package::Windows, :windows_only do
before(:each) do
- allow(Chef::Util::PathHelper).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
allow(Chef::FileCache).to receive(:create_cache_path).with("package/").and_return(cache_path)
end
diff --git a/spec/unit/provider/remote_file/fetcher_spec.rb b/spec/unit/provider/remote_file/fetcher_spec.rb
index b110e2c03a..a3ae60d6b0 100644
--- a/spec/unit/provider/remote_file/fetcher_spec.rb
+++ b/spec/unit/provider/remote_file/fetcher_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Lamont Granquist (<lamont@chef.io>)
-# Copyright:: Copyright 2013-2016, Chef Software Inc.
+# Copyright:: Copyright 2013-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,7 +27,7 @@ describe Chef::Provider::RemoteFile::Fetcher do
describe "when passed a network share" do
before do
expect(Chef::Provider::RemoteFile::NetworkFile).to receive(:new).and_return(fetcher_instance)
- allow(Chef::Platform).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
end
context "when host is a name" do
diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb
index 6dad6a57f2..43f38a0e00 100644
--- a/spec/unit/provider/remote_file/local_file_spec.rb
+++ b/spec/unit/provider/remote_file/local_file_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Provider::RemoteFile::LocalFile do
context "when parsing source path on windows" do
before do
- allow(Chef::Platform).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
end
describe "when given local unix path" do
diff --git a/spec/unit/provider/remote_file/network_file_spec.rb b/spec/unit/provider/remote_file/network_file_spec.rb
index 1c2bcc5911..07d8a402ca 100644
--- a/spec/unit/provider/remote_file/network_file_spec.rb
+++ b/spec/unit/provider/remote_file/network_file_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Provider::RemoteFile::NetworkFile do
let(:source_file) { double("::File", read: nil) }
before do
- allow(Chef::Platform).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
end
it "stages the local file to a temporary file" do
diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb
index 08b19730a7..036d742717 100644
--- a/spec/unit/provider/script_spec.rb
+++ b/spec/unit/provider/script_spec.rb
@@ -59,7 +59,7 @@ describe Chef::Provider::Script, "action_run" do
context "when configuring the script file's security" do
context "when not running on Windows" do
before do
- allow(::Chef::Platform).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
end
context "#set_owner_and_group" do
it "sets the owner and group for the script file" do
@@ -73,7 +73,7 @@ describe Chef::Provider::Script, "action_run" do
context "when running on Windows" do
before do
- allow(::Chef::Platform).to receive(:windows?).and_return(true)
+ allow(ChefHelpers).to receive(:windows?).and_return(true)
expect(new_resource.user).to eq(nil)
stub_const("Chef::ReservedNames::Win32::API::Security::GENERIC_READ", 1)
stub_const("Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE", 4)
diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb
index d3c5073b7e..68fc7b6cfa 100644
--- a/spec/unit/provider/subversion_spec.rb
+++ b/spec/unit/provider/subversion_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@kallistec.com>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -274,7 +274,7 @@ describe Chef::Provider::Subversion do
it "selects 'svn' as the binary by default" do
@resource.svn_binary nil
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
expect(@provider).to receive(:svn_binary).and_return("svn")
expect(@provider.export_command).to eql(
"svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
@@ -282,7 +282,7 @@ describe Chef::Provider::Subversion do
it "selects an svn binary with an exe extension on windows" do
@resource.svn_binary nil
- allow(ChefConfig).to receive(:windows?) { true }
+ allow(ChefHelpers).to receive(:windows?) { true }
expect(@provider).to receive(:svn_binary).and_return("svn.exe")
expect(@provider.export_command).to eql(
"svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir")
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index c93a1eb4a8..ebcc491ab0 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Dreamcat4 (<dreamcat4@gmail.com>)
-# Copyright:: Copyright 2009-2016, Chef Software Inc.
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@ require "ostruct"
describe Chef::Provider::User::Dscl do
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
end
let(:shellcmdresult) do
Struct.new(:stdout, :stderr, :exitstatus)
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index a3f2801adf..5c6b30906b 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -34,10 +34,6 @@ describe Chef::ProviderResolver do
# Root the filesystem under a temp directory so Chef.path_to will point at it
when_the_repository "is empty" do
- before do
- allow(Chef).to receive(:path_to) { |path| File.join(path_to(""), path) }
- end
-
let(:resource_name) { :service }
let(:provider) { nil }
let(:action) { :start }
@@ -145,51 +141,36 @@ describe Chef::ProviderResolver do
describe "resolving service resource" do
def stub_service_providers(*services)
- services.each do |service|
- case service
- when :debian
- file "usr/sbin/update-rc.d", ""
- when :invokercd
- file "usr/sbin/invoke-rc.d", ""
- when :insserv
- file "sbin/insserv", ""
- when :upstart
- file "sbin/initctl", ""
- when :redhat
- file "sbin/chkconfig", ""
- when :systemd
- file "proc/1/comm", "systemd\n"
- else
- raise ArgumentError, service
- end
+ allowed = [:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd]
+
+ (allowed - services).each do |api|
+ allow(Chef::Provider::Service).to receive(:"#{api}?").and_return(false)
+ end
+
+ raise ArgumentError unless (services - allowed).empty?
+
+ services.each do |api|
+ allow(Chef::Provider::Service).to receive(:"#{api}?").and_return(true)
end
end
def stub_service_configs(*configs)
- configs.each do |config|
- case config
- when :initd
- file "etc/init.d/#{service_name}", ""
- when :upstart
- file "etc/init/#{service_name}.conf", ""
- when :xinetd
- file "etc/xinetd.d/#{service_name}", ""
- when :etc_rcd
- file "etc/rc.d/#{service_name}", ""
- when :usr_local_etc_rcd
- file "usr/local/etc/rc.d/#{service_name}", ""
- when :systemd
- file "proc/1/comm", "systemd\n"
- file "etc/systemd/system/#{service_name}.service", ""
- else
- raise ArgumentError, config
- end
+ allowed = [:initd, :upstart, :xinetd, :systemd, :etc_rcd]
+
+ (allowed - configs).each do |type|
+ allow(Chef::Provider::Service).to receive(:service_script_exist?).with(type, service_name).and_return(false)
+ end
+
+ raise ArgumentError unless (configs - allowed).empty?
+
+ configs.each do |type|
+ allow(Chef::Provider::Service).to receive(:service_script_exist?).with(type, service_name).and_return(true)
end
end
shared_examples_for "an ubuntu platform with upstart, update-rc.d and systemd" do
before do
- stub_service_providers(:debian, :invokercd, :upstart, :systemd)
+ stub_service_providers(:debianrcd, :invokercd, :upstart, :systemd)
end
it "when both the SysV init and Systemd script exists, it returns a Service::Debian provider" do
@@ -213,12 +194,12 @@ describe Chef::ProviderResolver do
end
it "when only the SysV init script exists, it returns a Service::Systemd provider" do
- stub_service_configs(:initd)
+ stub_service_configs(:initd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
it "when both SysV and Upstart scripts exist, it returns a Service::Systemd provider" do
- stub_service_configs(:initd, :upstart)
+ stub_service_configs(:initd, :systemd, :upstart)
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
@@ -235,7 +216,7 @@ describe Chef::ProviderResolver do
shared_examples_for "an ubuntu platform with upstart and update-rc.d" do
before do
- stub_service_providers(:debian, :invokercd, :upstart)
+ stub_service_providers(:debianrcd, :invokercd, :upstart)
end
# needs to be handled by the highest priority init.d handler
@@ -362,7 +343,7 @@ describe Chef::ProviderResolver do
shared_examples_for "a debian platform using the insserv provider" do
context "with a default install" do
before do
- stub_service_providers(:debian, :invokercd, :insserv)
+ stub_service_providers(:debianrcd, :invokercd, :insserv)
end
it "uses the Service::Insserv Provider to manage sysv init scripts" do
@@ -378,7 +359,7 @@ describe Chef::ProviderResolver do
context "when the user has installed upstart" do
before do
- stub_service_providers(:debian, :invokercd, :insserv, :upstart)
+ stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart)
end
it "when only the SysV init script exists, it returns an Insserv provider" do
@@ -407,8 +388,8 @@ describe Chef::ProviderResolver do
it_behaves_like "an ubuntu platform with upstart, update-rc.d and systemd"
it "when the unit-files are missing and system-ctl list-unit-files returns an error" do
- stub_service_providers(:debian, :invokercd, :upstart, :systemd)
- stub_service_configs(:initd, :upstart)
+ stub_service_providers(:debianrcd, :invokercd, :upstart, :systemd)
+ stub_service_configs(:initd, :upstart, :systemd)
mock_shellout_command("/bin/systemctl list-unit-files", exitstatus: 1)
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
end
@@ -445,8 +426,8 @@ describe Chef::ProviderResolver do
it "always returns a Solaris provider" do
# no matter what we stub on the next two lines we should get a Solaris provider
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
- stub_service_configs(:initd, :upstart, :xinetd, :usr_local_etc_rcd, :systemd)
+ stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
+ stub_service_configs(:initd, :upstart, :xinetd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Solaris)
end
end
@@ -460,8 +441,8 @@ describe Chef::ProviderResolver do
it "always returns a Windows provider" do
# no matter what we stub on the next two lines we should get a Windows provider
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
- stub_service_configs(:initd, :upstart, :xinetd, :usr_local_etc_rcd, :systemd)
+ stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
+ stub_service_configs(:initd, :upstart, :xinetd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
end
end
@@ -475,8 +456,8 @@ describe Chef::ProviderResolver do
it "always returns a Macosx provider" do
# no matter what we stub on the next two lines we should get a Macosx provider
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
- stub_service_configs(:initd, :upstart, :xinetd, :usr_local_etc_rcd, :systemd)
+ stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
+ stub_service_configs(:initd, :upstart, :xinetd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
end
end
@@ -484,7 +465,6 @@ describe Chef::ProviderResolver do
on_platform "freebsd", os: "freebsd", platform_version: "10.3" do
it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
stub_service_providers
- stub_service_configs(:usr_local_etc_rcd)
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
end
@@ -495,15 +475,14 @@ describe Chef::ProviderResolver do
end
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
- # should only care about :usr_local_etc_rcd stub in the service configs
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
- stub_service_configs(:usr_local_etc_rcd, :initd, :upstart, :xinetd, :systemd)
+ stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
+ stub_service_configs(:initd, :upstart, :xinetd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
end
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
# should only care about :etc_rcd stub in the service configs
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
+ stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
stub_service_configs(:etc_rcd, :initd, :upstart, :xinetd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
end
@@ -518,7 +497,6 @@ describe Chef::ProviderResolver do
on_platform "netbsd", os: "netbsd", platform_version: "7.0.1" do
it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
stub_service_providers
- stub_service_configs(:usr_local_etc_rcd)
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
end
@@ -529,15 +507,14 @@ describe Chef::ProviderResolver do
end
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
- # should only care about :usr_local_etc_rcd stub in the service configs
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
- stub_service_configs(:usr_local_etc_rcd, :initd, :upstart, :xinetd, :systemd)
+ stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
+ stub_service_configs(:initd, :upstart, :xinetd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
end
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
# should only care about :etc_rcd stub in the service configs
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
+ stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
stub_service_configs(:etc_rcd, :initd, :upstart, :xinetd, :systemd)
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
end
diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb
index b35233649d..da3c80a729 100644
--- a/spec/unit/resource/cookbook_file_spec.rb
+++ b/spec/unit/resource/cookbook_file_spec.rb
@@ -53,7 +53,7 @@ describe Chef::Resource::CookbookFile do
describe "when it has a backup number, group, mode, owner, source, checksum, and cookbook on nix or path, rights, deny_rights, checksum on windows" do
before do
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
resource.path("C:/temp/origin/file.txt")
resource.rights(:read, "Everyone")
resource.deny_rights(:full_control, "Clumsy_Sam")
@@ -70,7 +70,7 @@ describe Chef::Resource::CookbookFile do
it "describes the state" do
state = resource.state_for_resource_reporter
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
puts state
expect(state[:rights]).to eq([{ permissions: :read, principals: "Everyone" }])
expect(state[:deny_rights]).to eq([{ permissions: :full_control, principals: "Clumsy_Sam" }])
@@ -83,7 +83,7 @@ describe Chef::Resource::CookbookFile do
end
it "returns the path as its identity" do
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
expect(resource.identity).to eq("C:/temp/origin/file.txt")
else
expect(resource.identity).to eq("/tmp/origin/file.txt")
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
index 39d34d9a96..dff6e0f70b 100644
--- a/spec/unit/resource/remote_file_spec.rb
+++ b/spec/unit/resource/remote_file_spec.rb
@@ -181,7 +181,7 @@ describe Chef::Resource::RemoteFile do
describe "when it has group, mode, owner, source, and checksum" do
before do
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
resource.path("C:/temp/origin/file.txt")
resource.rights(:read, "Everyone")
resource.deny_rights(:full_control, "Clumsy_Sam")
@@ -197,7 +197,7 @@ describe Chef::Resource::RemoteFile do
it "describes its state" do
state = resource.state_for_resource_reporter
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
puts state
expect(state[:rights]).to eq([{ permissions: :read, principals: "Everyone" }])
expect(state[:deny_rights]).to eq([{ permissions: :full_control, principals: "Clumsy_Sam" }])
@@ -210,7 +210,7 @@ describe Chef::Resource::RemoteFile do
end
it "returns the path as its identity" do
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
expect(resource.identity).to eq("C:/temp/origin/file.txt")
else
expect(resource.identity).to eq("/this/path/")
diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb
index 57f1d5c6ba..7d4d6dc881 100644
--- a/spec/unit/role_spec.rb
+++ b/spec/unit/role_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@ require "chef/role"
describe Chef::Role do
before(:each) do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefHelpers).to receive(:windows?) { false }
@role = Chef::Role.new
@role.name("ops_master")
end
diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb
index 8ba1afa72a..c915bb5798 100644
--- a/spec/unit/shell_spec.rb
+++ b/spec/unit/shell_spec.rb
@@ -43,7 +43,7 @@ describe Shell do
before do
Shell.irb_conf = {}
allow(Shell::ShellSession.instance).to receive(:reset!)
- allow(ChefConfig).to receive(:windows?).and_return(false)
+ allow(ChefHelpers).to receive(:windows?).and_return(false)
allow(Chef::Util::PathHelper).to receive(:home).and_return("/home/foo")
end
diff --git a/spec/unit/win32/error_spec.rb b/spec/unit/win32/error_spec.rb
index 316303ab4f..9991b149bd 100644
--- a/spec/unit/win32/error_spec.rb
+++ b/spec/unit/win32/error_spec.rb
@@ -17,7 +17,7 @@
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/error"
require "chef/win32/api/error"
end
diff --git a/spec/unit/win32/link_spec.rb b/spec/unit/win32/link_spec.rb
index 5f749c034e..08d5580518 100644
--- a/spec/unit/win32/link_spec.rb
+++ b/spec/unit/win32/link_spec.rb
@@ -16,7 +16,7 @@
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/api/file"
require "chef/win32/file"
require "chef/win32/version"
diff --git a/spec/unit/win32/security_spec.rb b/spec/unit/win32/security_spec.rb
index b5e441f2a0..88c4bb8670 100644
--- a/spec/unit/win32/security_spec.rb
+++ b/spec/unit/win32/security_spec.rb
@@ -17,7 +17,7 @@
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/win32/error"
require "chef/win32/security"
require "chef/win32/api/error"
diff --git a/spec/unit/windows_service_spec.rb b/spec/unit/windows_service_spec.rb
index 45af0f9d9f..9850bbd7c5 100644
--- a/spec/unit/windows_service_spec.rb
+++ b/spec/unit/windows_service_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
require "spec_helper"
-if Chef::Platform.windows?
+if ChefHelpers.windows?
require "chef/application/windows_service"
end