summaryrefslogtreecommitdiff
path: root/spec/unit/property
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-06-09 15:30:57 -0700
committerJohn Keiser <john@johnkeiser.com>2015-06-23 15:23:02 -0700
commit0a29c389d8dbc7c61fed13671e636480b8dd850e (patch)
tree95f99c94c6519c3d115fe006768e7197936cb60e /spec/unit/property
parent2054b5d58dda8c2ff500501ff2b6da0fb47a1a5b (diff)
downloadchef-0a29c389d8dbc7c61fed13671e636480b8dd850e.tar.gz
Fix set_or_return order: default->coerce->validate
Diffstat (limited to 'spec/unit/property')
-rw-r--r--spec/unit/property/validation_spec.rb54
1 files changed, 31 insertions, 23 deletions
diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb
index 14be7dc271..e32147bd38 100644
--- a/spec/unit/property/validation_spec.rb
+++ b/spec/unit/property/validation_spec.rb
@@ -3,7 +3,7 @@ require 'support/shared/integration/integration_helper'
describe "Chef::Resource.property validation" do
include IntegrationSupport
- class Namer
+ module Namer
@i = 0
def self.next_resource_name
"chef_resource_property_spec_#{@i += 1}"
@@ -519,24 +519,26 @@ describe "Chef::Resource.property validation" do
it "if x is not specified, retrieval fails" do
expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
end
- it "value nil is invalid" do
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
- end
it "value 1 is valid" do
expect(resource.x 1).to eq 1
expect(resource.x).to eq 1
end
+ it "value nil does a get" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ resource.x 1
+ resource.x nil
+ expect(resource.x).to eq 1
+ end
end
with_property ':x, [String, nil], required: true' do
it "if x is not specified, retrieval fails" do
expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
end
- # it "value nil is valid" do
- # expect(resource.x nil).to be_nil
- # expect(resource.x).to be_nil
- # end
+ it "value nil is valid" do
+ expect(resource.x nil).to be_nil
+ expect(resource.x).to be_nil
+ end
it "value '1' is valid" do
expect(resource.x '1').to eq '1'
expect(resource.x).to eq '1'
@@ -546,32 +548,34 @@ describe "Chef::Resource.property validation" do
end
end
- # with_property ':x, name_property: true, required: true' do
- with_property ':x, required: true, name_property: true' do
+ with_property ':x, name_property: true, required: true' do
it "if x is not specified, retrieval fails" do
expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
end
- it "value nil is invalid" do
- expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
- end
it "value 1 is valid" do
expect(resource.x 1).to eq 1
expect(resource.x).to eq 1
end
+ it "value nil does a get" do
+ resource.x 1
+ resource.x nil
+ expect(resource.x).to eq 1
+ end
end
- # with_property ':x, default: 10, required: true' do
- with_property ':x, required: true, default: 10' do
+ with_property ':x, default: 10, required: true' do
it "if x is not specified, retrieval fails" do
expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed
end
- it "value nil is invalid" do
- expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
- end
it "value 1 is valid" do
expect(resource.x 1).to eq 1
expect(resource.x).to eq 1
end
+ it "value nil does a get" do
+ resource.x 1
+ resource.x nil
+ expect(resource.x).to eq 1
+ end
end
end
@@ -607,9 +611,11 @@ describe "Chef::Resource.property validation" do
expect { resource.x '1' }.to raise_error Chef::Exceptions::ValidationFailed
end
- it "value nil is invalid" do
+ it "value nil does a get" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
+ resource.x 1
+ resource.x nil
+ expect(resource.x).to eq 1
end
end
end
@@ -635,8 +641,10 @@ describe "Chef::Resource.property validation" do
expect { resource.x '1' }.to raise_error Chef::Exceptions::ValidationFailed
end
- it "value nil is invalid" do
- expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
+ it "value nil does a get" do
+ resource.x 1
+ resource.x nil
+ expect(resource.x).to eq 1
end
end
end