diff options
| author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-19 14:40:06 -0800 |
|---|---|---|
| committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-23 10:14:04 -0800 |
| commit | 30520d738a3683b15a70d43dd9cf1aa3da61686d (patch) | |
| tree | c4b12e272e54d52f35f4123be1067afb4b78f5fc /spec/unit/resource | |
| parent | a7f5c92960aedf8d5bfc71abbce430ab075e016a (diff) | |
| download | chef-30520d738a3683b15a70d43dd9cf1aa3da61686d.tar.gz | |
nillable deploy resource + nillable LWRP args
introduced nillable_set_or_return so that we can actually set a nil value
on a resource from the DSL.
this fixes the case where you want to do (and we document) setting
symlink_before_migrate to nil on the deploy resource.
to implement this better also moved up the attribute DSL method to the
base Chef::Resource class.
all LWRP resources are now nillable as well.
Diffstat (limited to 'spec/unit/resource')
| -rw-r--r-- | spec/unit/resource/deploy_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb index 0403a7ba6b..07f5f973c0 100644 --- a/spec/unit/resource/deploy_spec.rb +++ b/spec/unit/resource/deploy_spec.rb @@ -30,12 +30,35 @@ describe Chef::Resource::Deploy do class << self + + def resource_has_a_hash_attribute(attr_name) + it "has a Hash attribute for #{attr_name.to_s}" do + @resource.send(attr_name, {foo: "bar"}) + expect(@resource.send(attr_name)).to eql({foo: "bar"}) + expect {@resource.send(attr_name, 8675309)}.to raise_error(ArgumentError) + end + + it "the Hash attribute for #{attr_name.to_s} is nillable" do + @resource.send(attr_name, {foo: "bar"}) + expect(@resource.send(attr_name)).to eql({foo: "bar"}) + @resource.send(attr_name, nil) + expect(@resource.send(attr_name)).to eql(nil) + end + end + def resource_has_a_string_attribute(attr_name) it "has a String attribute for #{attr_name.to_s}" do @resource.send(attr_name, "this is a string") expect(@resource.send(attr_name)).to eql("this is a string") expect {@resource.send(attr_name, 8675309)}.to raise_error(ArgumentError) end + + it "the String attribute for #{attr_name.to_s} is nillable" do + @resource.send(attr_name, "this is a string") + expect(@resource.send(attr_name)).to eql("this is a string") + @resource.send(attr_name, nil) + expect(@resource.send(attr_name)).to eql(nil) + end end def resource_has_a_boolean_attribute(attr_name, opts={:defaults_to=>false}) @@ -189,6 +212,10 @@ describe Chef::Resource::Deploy do expect(@resource.symlink_before_migrate).to eq({"wtf?" => "wtf is going on"}) end + resource_has_a_hash_attribute :symlink_before_migrate + resource_has_a_hash_attribute :symlinks + resource_has_a_hash_attribute :additional_remotes + resource_has_a_callback_attribute :before_migrate resource_has_a_callback_attribute :before_symlink resource_has_a_callback_attribute :before_restart |
