summaryrefslogtreecommitdiff
path: root/spec/unit/resource/directory_spec.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-12-18 16:53:17 -0800
committerTim Smith <tsmith@chef.io>2017-12-18 16:53:17 -0800
commit17f85426ed747ce7ba3e56a2bce241b317fb99ae (patch)
tree0ce1748290003126e3772bf3b4d2fc2358695894 /spec/unit/resource/directory_spec.rb
parent7556053a3cc06db5ef778526a025e408f5e1b397 (diff)
downloadchef-17f85426ed747ce7ba3e56a2bce241b317fb99ae.tar.gz
Cleanup for resource specs
Convert everything to let and update the tense Nothing real magical here, but gets us one step closer to uniformity in the specs Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec/unit/resource/directory_spec.rb')
-rw-r--r--spec/unit/resource/directory_spec.rb59
1 files changed, 28 insertions, 31 deletions
diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb
index b3a0134024..5d1e24cbb0 100644
--- a/spec/unit/resource/directory_spec.rb
+++ b/spec/unit/resource/directory_spec.rb
@@ -20,63 +20,60 @@
require "spec_helper"
describe Chef::Resource::Directory do
+ let(:resource) { Chef::Resource::Directory.new("fakey_fakerton") }
- before(:each) do
- @resource = Chef::Resource::Directory.new("fakey_fakerton")
+ it "creates a new Chef::Resource::Directory" do
+ expect(resource).to be_a_kind_of(Chef::Resource)
+ expect(resource).to be_a_kind_of(Chef::Resource::Directory)
end
- it "should create a new Chef::Resource::Directory" do
- expect(@resource).to be_a_kind_of(Chef::Resource)
- expect(@resource).to be_a_kind_of(Chef::Resource::Directory)
+ it "has a name" do
+ expect(resource.name).to eql("fakey_fakerton")
end
- it "should have a name" do
- expect(@resource.name).to eql("fakey_fakerton")
+ it "has a default action of 'create'" do
+ expect(resource.action).to eql([:create])
end
- it "should have a default action of 'create'" do
- expect(@resource.action).to eql([:create])
+ it "accepts create or delete for action" do
+ expect { resource.action :create }.not_to raise_error
+ expect { resource.action :delete }.not_to raise_error
+ expect { resource.action :blues }.to raise_error(ArgumentError)
end
- it "should accept create or delete for action" do
- expect { @resource.action :create }.not_to raise_error
- expect { @resource.action :delete }.not_to raise_error
- expect { @resource.action :blues }.to raise_error(ArgumentError)
+ it "uses the object name as the path by default" do
+ expect(resource.path).to eql("fakey_fakerton")
end
- it "should use the object name as the path by default" do
- expect(@resource.path).to eql("fakey_fakerton")
+ it "accepts a string as the path" do
+ expect { resource.path "/tmp" }.not_to raise_error
+ expect(resource.path).to eql("/tmp")
+ expect { resource.path Hash.new }.to raise_error(ArgumentError)
end
- it "should accept a string as the path" do
- expect { @resource.path "/tmp" }.not_to raise_error
- expect(@resource.path).to eql("/tmp")
- expect { @resource.path Hash.new }.to raise_error(ArgumentError)
- end
-
- it "should allow you to have specify whether the action is recursive with true/false" do
- expect { @resource.recursive true }.not_to raise_error
- expect { @resource.recursive false }.not_to raise_error
- expect { @resource.recursive "monkey" }.to raise_error(ArgumentError)
+ it "allows you to have specify whether the action is recursive with true/false" do
+ expect { resource.recursive true }.not_to raise_error
+ expect { resource.recursive false }.not_to raise_error
+ expect { resource.recursive "monkey" }.to raise_error(ArgumentError)
end
describe "when it has group, mode, and owner" do
before do
- @resource.path("/tmp/foo/bar/")
- @resource.group("wheel")
- @resource.mode("0664")
- @resource.owner("root")
+ resource.path("/tmp/foo/bar/")
+ resource.group("wheel")
+ resource.mode("0664")
+ resource.owner("root")
end
it "describes its state" do
- state = @resource.state_for_resource_reporter
+ state = resource.state_for_resource_reporter
expect(state[:group]).to eq("wheel")
expect(state[:mode]).to eq("0664")
expect(state[:owner]).to eq("root")
end
it "returns the directory path as its identity" do
- expect(@resource.identity).to eq("/tmp/foo/bar/")
+ expect(resource.identity).to eq("/tmp/foo/bar/")
end
end
end