diff options
author | nimisha <nimisha.sharad@clogeny.com> | 2016-09-01 17:47:21 +0530 |
---|---|---|
committer | nimisha <nimisha.sharad@clogeny.com> | 2016-09-16 14:02:50 +0530 |
commit | 11307e427d43172a4131cd56fdc3bd1ab77e115d (patch) | |
tree | d49f608ec8b67574d27717a30164a01fb823fe85 /spec | |
parent | cf35dffacad11a139e363f22162c8477a402f917 (diff) | |
download | chef-11307e427d43172a4131cd56fdc3bd1ab77e115d.tar.gz |
Added specs for update_resource_count attribute
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/log_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/resource/log_spec.rb | 15 |
2 files changed, 29 insertions, 0 deletions
diff --git a/spec/unit/provider/log_spec.rb b/spec/unit/provider/log_spec.rb index 2e4f9c4e52..7d63e1dbd5 100644 --- a/spec/unit/provider/log_spec.rb +++ b/spec/unit/provider/log_spec.rb @@ -72,4 +72,18 @@ describe Chef::Provider::Log::ChefLog do expect(Chef::Log).to receive(:info).with(log_str).and_return(true) provider.run_action(:write) end + + context "when update_resource_count attribute is passed" do + it 'updates the resource count if update_resource_count=true' do + new_resource.update_resource_count true + expect(new_resource).to receive(:updated_by_last_action) + provider.run_action(:write) + end + + it "doesn't update the resource count if update_resource_count=false" do + new_resource.update_resource_count false + expect(new_resource).not_to receive(:updated_by_last_action) + provider.run_action(:write) + end + end end diff --git a/spec/unit/resource/log_spec.rb b/spec/unit/resource/log_spec.rb index 18a1eb65bf..a5c718791e 100644 --- a/spec/unit/resource/log_spec.rb +++ b/spec/unit/resource/log_spec.rb @@ -70,4 +70,19 @@ describe Chef::Resource::Log do expect(@resource.identity).to eq("ery day I'm loggin-in") end end + + context "update_resource_count attribute" do + it "sets the default value of update_resource_count as true" do + expect(@resource.update_resource_count).to eq(true) + end + + it 'accepts a boolean value for update_resource_count attribute' do + @resource.update_resource_count false + expect(@resource.update_resource_count).to eq(false) + end + + it 'raises error if a non-boolean value is passed for update_resource_count attribute' do + expect{ @resource.update_resource_count "abc" }.to raise_error(Chef::Exceptions::ValidationFailed) + end + end end |