diff options
author | mwrock <matt@mattwrock.com> | 2020-11-30 16:03:17 -0800 |
---|---|---|
committer | mwrock <matt@mattwrock.com> | 2020-11-30 16:03:17 -0800 |
commit | 63c8079bc281048f4327c1e4912b88859a7eef69 (patch) | |
tree | 51204eb56c0f8ed3edace668f32f251e4cf5f8dd | |
parent | 6408c925c03bb44ea3ae2194c064815177497d2e (diff) | |
download | chef-63c8079bc281048f4327c1e4912b88859a7eef69.tar.gz |
responding to feedback
Signed-off-by: mwrock <matt@mattwrock.com>
-rw-r--r-- | lib/chef/provider/dsc_script.rb | 5 | ||||
-rw-r--r-- | lib/chef/util/dsc/configuration_generator.rb | 2 | ||||
-rw-r--r-- | lib/chef/util/dsc/lcm_output_parser.rb | 3 | ||||
-rw-r--r-- | spec/functional/resource/dsc_script_spec.rb | 7 | ||||
-rw-r--r-- | spec/unit/util/dsc/configuration_generator_spec.rb | 4 |
5 files changed, 8 insertions, 13 deletions
diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb index 3e257492e7..5df45f2e7e 100644 --- a/lib/chef/provider/dsc_script.rb +++ b/lib/chef/provider/dsc_script.rb @@ -88,7 +88,7 @@ class Chef original_env = ENV.to_hash begin - ENV.update(@dsc_resource.environment || original_env) + ENV.update(@dsc_resource.environmen) if @dsc_resource.environment Dir.chdir(cwd) do Timeout.timeout(@dsc_resource.timeout) do configuration_document = generate_configuration_document(config_directory, configuration_flags) @@ -100,8 +100,7 @@ class Chef raise e ensure ::FileUtils.rm_rf(config_directory) - ENV.clear - ENV.update(original_env) + ENV.replace(original_env) end end diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb index 25b6110464..7e78e1ecab 100644 --- a/lib/chef/util/dsc/configuration_generator.rb +++ b/lib/chef/util/dsc/configuration_generator.rb @@ -58,7 +58,7 @@ class Chef::Util::DSC protected def validate_switch_name!(switch_parameter_name) - if !!(switch_parameter_name =~ /\A[A-Za-z]+[_a-zA-Z0-9]*\Z/) == false + unless switch_parameter_name.match?(/\A[A-Za-z]+[_a-zA-Z0-9]*\Z/) raise ArgumentError, "`#{switch_parameter_name}` is not a valid PowerShell cmdlet switch parameter name" end end diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb index cccf30c182..d05ea3ba68 100644 --- a/lib/chef/util/dsc/lcm_output_parser.rb +++ b/lib/chef/util/dsc/lcm_output_parser.rb @@ -75,8 +75,7 @@ class Chef # def self.parse(lcm_output, test_dsc_configuration) - lcm_output ||= "" - lcm_output = lcm_output.split("\n") + lcm_output = String(lcm_output).split("\n") test_dsc_configuration ? test_dsc_parser(lcm_output) : what_if_parser(lcm_output) end diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 60197c8643..87c624e85f 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -261,12 +261,9 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do it "should raise an exception if the cwd is etc" do dsc_test_resource.cwd(dsc_environment_fail_etc_directory) - expect { dsc_test_resource.run_action(:run) }.to raise_error(Chef::PowerShell::CommandFailed) - begin + expect { dsc_test_resource.run_action(:run) - rescue Chef::PowerShell::CommandFailed => e - expect(e.message).to match(exception_message_signature) - end + }.to raise_error(Chef::PowerShell::CommandFailed, /#{exception_message_signature}/) end end end diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb index 981b99af0e..3f85f3189d 100644 --- a/spec/unit/util/dsc/configuration_generator_spec.rb +++ b/spec/unit/util/dsc/configuration_generator_spec.rb @@ -39,7 +39,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do end %w{! @ # $ % ^ & * & * ( ) - = + \{ \} . ? < > \\ /}.each do |sym| - it "raises an Argument error if it configuration name contains #{sym}" do + it "raises an ArgumentError if configuration name contains #{sym}" do expect do conf_man.send(:validate_switch_name!, "Hello#{sym}") end.to raise_error(ArgumentError) @@ -50,7 +50,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do describe "#escape_parameter_value" do # Is this list really complete? %w{` " # '}.each do |c| - it "escapse #{c}" do + it "escapes #{c}" do expect(conf_man.send(:escape_parameter_value, "stuff #{c}")).to eql("stuff `#{c}") end end |