diff options
author | nimisha <nimisha.sharad@clogeny.com> | 2017-08-03 16:23:48 +0530 |
---|---|---|
committer | nimisha <nimisha.sharad@clogeny.com> | 2017-08-16 14:49:09 +0530 |
commit | 300fd3e5fdfc88fec26f8ff955b4a1ba96c9c0be (patch) | |
tree | 2fac88eff4fb2b0f960f8ea79bf749593da1dad6 | |
parent | 68a3098e04b6f9a79ded4b555d81ae9fbac6c176 (diff) | |
download | chef-300fd3e5fdfc88fec26f8ff955b4a1ba96c9c0be.tar.gz |
Fixing Appveyor issues
Signed-off-by: nimisha <nimisha.sharad@clogeny.com>
-rw-r--r-- | lib/chef/provider/windows_path.rb | 1 | ||||
-rw-r--r-- | spec/functional/resource/windows_path_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/provider/windows_path_spec.rb | 19 |
3 files changed, 26 insertions, 2 deletions
diff --git a/lib/chef/provider/windows_path.rb b/lib/chef/provider/windows_path.rb index cc03341c05..7158ab2df8 100644 --- a/lib/chef/provider/windows_path.rb +++ b/lib/chef/provider/windows_path.rb @@ -36,6 +36,7 @@ class Chef delim ::File::PATH_SEPARATOR value new_resource.path.tr("/", '\\') end + # Expands environment-variable strings and replaces them with the values defined for the current user ENV["PATH"] = expand_env_vars(ENV["PATH"]) end diff --git a/spec/functional/resource/windows_path_spec.rb b/spec/functional/resource/windows_path_spec.rb index 0edda6a58d..912abe6b24 100644 --- a/spec/functional/resource/windows_path_spec.rb +++ b/spec/functional/resource/windows_path_spec.rb @@ -21,6 +21,14 @@ require "spec_helper" describe Chef::Resource::WindowsPath, :windows_only do let(:path) { "test_path" } + before(:all) do + @old_path = ENV["PATH"].dup + end + + after(:all) do + ENV["PATH"] = @old_path + end + subject do new_resource = Chef::Resource::WindowsPath.new(path, run_context) new_resource diff --git a/spec/unit/provider/windows_path_spec.rb b/spec/unit/provider/windows_path_spec.rb index a43c13f049..1ff7e98f8c 100644 --- a/spec/unit/provider/windows_path_spec.rb +++ b/spec/unit/provider/windows_path_spec.rb @@ -19,6 +19,14 @@ require "spec_helper" describe Chef::Provider::WindowsPath, :windows_only do + before(:all) do + @old_path = ENV["PATH"].dup + end + + after(:all) do + ENV["PATH"] = @old_path + end + let(:new_resource) { Chef::Resource::WindowsPath.new("some_path") } let(:provider) do @@ -56,13 +64,20 @@ describe Chef::Provider::WindowsPath, :windows_only do end describe "#expand_env_vars" do - context "when ExpandEnvironmentStrings succeeds" do - it "returns the expanded environment variable" do + context "when a simple path is given" do + it "doesn't expand the environment variable" do expanded_var = provider.expand_env_vars("some_path") expect(expanded_var).to eq("some_path") end end + context "when an environment variable string is provided" do + it "expands the environment variable" do + expanded_var = provider.expand_env_vars("%WINDIR%") + expect(expanded_var).to match(/C:\\Windows/i) + end + end + context "when ExpandEnvironmentStrings fails" do it "raises error" do allow(Chef::Provider::WindowsPath::ExpandEnvironmentStrings).to receive(:call).and_return(0) |