blob: 9eab495f7742ba1a0cad927795b85922f01af3ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
#
# Author:: Adam Jacob (<adam@chef.io>)
# Copyright:: Copyright 2008-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require "spec_helper"
describe Chef::Resource::RemoteDirectory do
let(:resource) { Chef::Resource::RemoteDirectory.new("/etc/dunk") }
it "the path property is the name_property" do
expect(resource.path).to eql("/etc/dunk")
end
it "sets the default action as :create" do
expect(resource.action).to eql([:create])
end
it "supports :create, :create_if_missing, :delete actions" do
expect { resource.action :create }.not_to raise_error
expect { resource.action :create_if_missing }.not_to raise_error
expect { resource.action :delete }.not_to raise_error
end
it "accepts a String for the cookbook property" do
resource.cookbook "foo"
expect(resource.cookbook).to eql("foo")
end
it "accepts a String for the source property" do
resource.source "foo"
expect(resource.source).to eql("foo")
end
it "uses the basename of the pat property as the default value of the source property" do
resource.path "/foo/bar"
expect(resource.source).to eql("bar")
end
it "files_backup property defaults to 5" do
expect(resource.files_backup).to eql(5)
end
it "accepts an Integer for the files_backup property" do
resource.files_backup 1
expect(resource.files_backup).to eql(1)
end
it "accepts false for the files_backup property" do
resource.files_backup false
expect(resource.files_backup).to eql(false)
end
it "accepts 3 or 4 digits for the files_mode property" do
resource.files_mode 100
expect(resource.files_mode).to eql(100)
resource.files_mode 1000
expect(resource.files_mode).to eql(1000)
end
it "accepts a String or number for the files_group property" do
resource.files_group "heart"
expect(resource.files_group).to eql("heart")
resource.files_group 1000
expect(resource.files_group).to eql(1000)
end
it "accepts a String or number for the files_owner property" do
resource.files_owner "heart"
expect(resource.files_owner).to eql("heart")
resource.files_owner 1000
expect(resource.files_owner).to eql(1000)
end
it "overwrite property has the default value of true" do
expect(resource.overwrite).to be true
end
it "recursive property has the default value of true" do
expect(resource.recursive).to be true
end
describe "when it has cookbook, files owner, files mode, and source" do
before do
resource.path("/var/path/")
resource.cookbook("pokemon.rb")
resource.files_owner("root")
resource.files_group("supergroup")
resource.files_mode("0664")
resource.source("/var/source/")
end
it "describes its state" do
state = resource.state_for_resource_reporter
expect(state[:files_owner]).to eq("root")
expect(state[:files_group]).to eq("supergroup")
expect(state[:files_mode]).to eq("0664")
end
it "returns the path as its identity" do
expect(resource.identity).to eq("/var/path/")
end
end
end
|