summaryrefslogtreecommitdiff
path: root/spec/unit/provider
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-11-08 14:06:33 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2019-11-08 14:06:33 -0800
commit8a7e29d52882c39d0c903eef83bd3472e4f334af (patch)
treea25a7b76416e07ebdb54e569fb0006079cf012db /spec/unit/provider
parentc31625406530b560fab02b11fa2447955ed2faef (diff)
downloadchef-8a7e29d52882c39d0c903eef83bd3472e4f334af.tar.gz
Add chef-utils gem with various recipe DSL helpers
This is the implementation of [RFC-087](https://github.com/chef-boneyard/chef-rfc/blob/master/rfc087-distro-sugar-helpers.md) although some of the specifics have been iterated on and changed. The documentation will be in the [README.md](https://github.com/chef/chef/tree/master/chef-utils/README.md) once this is merged. While this PR mostly moves chef-sugar utilities into core-chef via this chef-utils gem, the scope of the chef-utils gem should be considered larger than just that. As an example this PR moves the Mash class into this gem for reuse in ohai as well. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/unit/provider')
-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.rb2
10 files changed, 19 insertions, 19 deletions
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index 11eb70e396..60f2070c1c 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(ChefUtils).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 fff2c1ffa8..154197e730 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 ChefUtils.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
+ ChefUtils.windows? ? path.tr("/", '\\') : path
end
describe "when the target is a symlink" do
@@ -359,7 +359,7 @@ describe Chef::Resource::Link do
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(ChefUtils).to receive(:windows?).and_return(true)
end
context "soft links" do
@@ -389,7 +389,7 @@ describe Chef::Resource::Link do
context "on Linux platform" do
before(:each) do
- allow(Chef::Platform).to receive(:windows?).and_return(false)
+ allow(ChefUtils).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 6e39ddc78a..2ed4c03905 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 ChefUtils.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 2fafb3bd0e..ddb2448801 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(ChefUtils).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..254a9d36ec 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(ChefUtils).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..cfca09ad18 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(ChefUtils).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..5eb8c8e3e5 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(ChefUtils).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..68d6bdb697 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(ChefUtils).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(ChefUtils).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 a70b7cd48b..9f5ffacec6 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(ChefUtils).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"
@@ -283,7 +283,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(ChefUtils).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 e20873dc92..5ef47170c0 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -21,7 +21,7 @@ require "ostruct"
describe Chef::Provider::User::Dscl do
before do
- allow(ChefConfig).to receive(:windows?) { false }
+ allow(ChefUtils).to receive(:windows?) { false }
end
let(:shellcmdresult) { Struct.new(:stdout, :stderr, :exitstatus) }