summaryrefslogtreecommitdiff
path: root/spec/unit/provider/env_spec.rb
diff options
context:
space:
mode:
authorPierre Ynard <p.ynard@criteo.com>2014-07-02 17:56:44 +0200
committerPierre Ynard <p.ynard@criteo.com>2014-07-02 17:56:44 +0200
commit9459638a8db3f2716b9b9c7f6bd63df70e78caac (patch)
tree6295ceb5569be4980d295691ec078eddedd9cc6c /spec/unit/provider/env_spec.rb
parenta06bc951fc9ac04200988f596c04cdf5c686e04e (diff)
downloadchef-9459638a8db3f2716b9b9c7f6bd63df70e78caac.tar.gz
Don't modify variable passed to env resource when updating
When using a delimiter, the passed value is prepended to the given environment variable. Unfortunately this has the side effect of modifying the variable passed to the resource. Oftentimes this is an attribute, used somewhere else after that, with the wrong, modified value.
Diffstat (limited to 'spec/unit/provider/env_spec.rb')
-rw-r--r--spec/unit/provider/env_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/unit/provider/env_spec.rb b/spec/unit/provider/env_spec.rb
index 0bc5117e48..dc6176d45c 100644
--- a/spec/unit/provider/env_spec.rb
+++ b/spec/unit/provider/env_spec.rb
@@ -229,4 +229,23 @@ describe Chef::Provider::Env do
@provider.compare_value.should be_true
end
end
+
+ describe "modify_env" do
+ before(:each) do
+ @provider.stub(:create_env).and_return(true)
+ @new_resource.delim ";"
+
+ @current_resource = Chef::Resource::Env.new("FOO")
+ @current_resource.value "C:/foo/bin"
+ @provider.current_resource = @current_resource
+ end
+
+ it "should not modify the variable passed to the resource" do
+ new_value = "C:/bar/bin"
+ passed_value = new_value.dup
+ @new_resource.value(passed_value)
+ @provider.modify_env
+ passed_value.should == new_value
+ end
+ end
end