diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-11-08 14:06:33 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-11-08 14:06:33 -0800 |
commit | 8a7e29d52882c39d0c903eef83bd3472e4f334af (patch) | |
tree | a25a7b76416e07ebdb54e569fb0006079cf012db /chef-config/spec | |
parent | c31625406530b560fab02b11fa2447955ed2faef (diff) | |
download | chef-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 'chef-config/spec')
-rw-r--r-- | chef-config/spec/spec_helper.rb | 6 | ||||
-rw-r--r-- | chef-config/spec/unit/config_spec.rb | 2 | ||||
-rw-r--r-- | chef-config/spec/unit/fips_spec.rb | 6 | ||||
-rw-r--r-- | chef-config/spec/unit/path_helper_spec.rb | 12 | ||||
-rw-r--r-- | chef-config/spec/unit/workstation_config_loader_spec.rb | 6 |
5 files changed, 16 insertions, 16 deletions
diff --git a/chef-config/spec/spec_helper.rb b/chef-config/spec/spec_helper.rb index 6a324474e1..557f1f6432 100644 --- a/chef-config/spec/spec_helper.rb +++ b/chef-config/spec/spec_helper.rb @@ -1,4 +1,4 @@ -require "chef-config/windows" +require "chef-utils" # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| @@ -32,8 +32,8 @@ RSpec.configure do |config| config.filter_run :focus config.run_all_when_everything_filtered = true - config.filter_run_excluding windows_only: true unless ChefConfig.windows? - config.filter_run_excluding unix_only: true if ChefConfig.windows? + config.filter_run_excluding windows_only: true unless ChefUtils.windows? + config.filter_run_excluding unix_only: true if ChefUtils.windows? # Limits the available syntax to the non-monkey patched syntax that is # recommended. For more details, see: diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb index dec5b8755f..674246dfd1 100644 --- a/chef-config/spec/unit/config_spec.rb +++ b/chef-config/spec/unit/config_spec.rb @@ -201,7 +201,7 @@ RSpec.describe ChefConfig::Config do end before :each do - allow(ChefConfig).to receive(:windows?).and_return(is_windows) + allow(ChefUtils).to receive(:windows?).and_return(is_windows) end describe "class method: windows_installation_drive" do before do diff --git a/chef-config/spec/unit/fips_spec.rb b/chef-config/spec/unit/fips_spec.rb index d53096cead..d618117b57 100644 --- a/chef-config/spec/unit/fips_spec.rb +++ b/chef-config/spec/unit/fips_spec.rb @@ -1,6 +1,6 @@ # # Author:: Matt Wrock (<matt@mattwrock.com>) -# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. +# Copyright:: Copyright (c) 2016-2018, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +32,7 @@ RSpec.describe "ChefConfig.fips?" do let(:fips_path) { "/proc/sys/crypto/fips_enabled" } before(:each) do - allow(ChefConfig).to receive(:windows?).and_return(false) + allow(ChefUtils).to receive(:windows?).and_return(false) allow(::File).to receive(:exist?).with(fips_path).and_return(true) allow(::File).to receive(:read).with(fips_path).and_return(enabled) end @@ -69,7 +69,7 @@ RSpec.describe "ChefConfig.fips?" do let(:win_reg_entry) { { "Enabled" => enabled } } before(:each) do - allow(ChefConfig).to receive(:windows?).and_return(true) + allow(ChefUtils).to receive(:windows?).and_return(true) allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with(fips_key, arch).and_yield(win_reg_entry) end diff --git a/chef-config/spec/unit/path_helper_spec.rb b/chef-config/spec/unit/path_helper_spec.rb index 399b3dc965..1a0c2660e0 100644 --- a/chef-config/spec/unit/path_helper_spec.rb +++ b/chef-config/spec/unit/path_helper_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"); @@ -58,7 +58,7 @@ RSpec.describe ChefConfig::PathHelper do context "on windows" do before(:each) do - allow(ChefConfig).to receive(:windows?).and_return(true) + allow(ChefUtils).to receive(:windows?).and_return(true) end include_examples("common_functionality") @@ -106,7 +106,7 @@ RSpec.describe ChefConfig::PathHelper do context "on unix" do before(:each) do - allow(ChefConfig).to receive(:windows?).and_return(false) + allow(ChefUtils).to receive(:windows?).and_return(false) end include_examples("common_functionality") @@ -144,7 +144,7 @@ RSpec.describe ChefConfig::PathHelper do context "on windows" do before(:each) do # pass by default - allow(ChefConfig).to receive(:windows?).and_return(true) + allow(ChefUtils).to receive(:windows?).and_return(true) allow(path_helper).to receive(:printable?).and_return(true) allow(path_helper).to receive(:windows_max_length_exceeded?).and_return(false) end @@ -254,7 +254,7 @@ RSpec.describe ChefConfig::PathHelper do context "when given more than one argument" do it "joins, cleanpaths, and escapes characters reserved by glob" do args = ["this/*path", "[needs]", "escaping?"] - escaped_path = if ChefConfig.windows? + escaped_path = if ChefUtils.windows? "this\\\\\\*path\\\\\\[needs\\]\\\\escaping\\?" else "this/\\*path/\\[needs\\]/escaping\\?" @@ -286,7 +286,7 @@ RSpec.describe ChefConfig::PathHelper do describe "all_homes" do before do stub_const("ENV", env) - allow(ChefConfig).to receive(:windows?).and_return(is_windows) + allow(ChefUtils).to receive(:windows?).and_return(is_windows) end context "on windows" do diff --git a/chef-config/spec/unit/workstation_config_loader_spec.rb b/chef-config/spec/unit/workstation_config_loader_spec.rb index e1cab3d4d0..704c3ac2dc 100644 --- a/chef-config/spec/unit/workstation_config_loader_spec.rb +++ b/chef-config/spec/unit/workstation_config_loader_spec.rb @@ -20,7 +20,7 @@ require "spec_helper" require "tempfile" require "chef-config/exceptions" -require "chef-config/windows" +require "chef-utils" require "chef-config/workstation_config_loader" RSpec.describe ChefConfig::WorkstationConfigLoader do @@ -98,7 +98,7 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do let(:env_pwd) { "/path/to/cwd" } before do - if ChefConfig.windows? + if ChefUtils.windows? env["CD"] = env_pwd else env["PWD"] = env_pwd @@ -431,7 +431,7 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do end describe "when loading a credentials file" do - if ChefConfig.windows? + if ChefUtils.windows? let(:home) { "C:/Users/example.user" } else let(:home) { "/Users/example.user" } |