diff options
author | John Keiser <john@johnkeiser.com> | 2015-10-08 20:24:55 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-10-08 20:25:47 -0700 |
commit | c9473b61e7d5f6f48598acaef4af0cfdf821f579 (patch) | |
tree | c4ab7ac6ddc1748bfb049693fae1f234432d2d04 /spec/unit/property_spec.rb | |
parent | 56b3c90bbd7c4657533b99d04dcdc3419dcd472b (diff) | |
download | chef-c9473b61e7d5f6f48598acaef4af0cfdf821f579.tar.gz |
Accept coercion as a way to accept nil values
Diffstat (limited to 'spec/unit/property_spec.rb')
-rw-r--r-- | spec/unit/property_spec.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 9ecf7a4cde..dc06cb3326 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -921,6 +921,9 @@ describe "Chef::Resource.property" do expect(resource.x 10).to eq "101" expect(Namer.current_index).to eq 1 end + it "does not emit a deprecation warning if set to nil" do + expect(resource.x nil).to eq "1" + end it "coercion sets the value (and coercion does not run on get)" do expect(resource.x 10).to eq "101" expect(resource.x).to eq "101" @@ -933,6 +936,11 @@ describe "Chef::Resource.property" do expect(Namer.current_index).to eq 2 end end + with_property ':x, coerce: proc { |x| x }' do + it "does not emit a deprecation warning if set to nil" do + expect(resource.x nil).to be_nil + end + end with_property ':x, coerce: proc { |x| Namer.next_index; raise "hi" if x == 10; x }, is: proc { |x| Namer.next_index; x != 10 }' do it "failed coercion fails to set the value" do resource.x 20 |