cheffish 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/Rakefile +24 -12
- data/cheffish.gemspec +15 -15
- data/lib/chef/resource/chef_acl.rb +63 -63
- data/lib/chef/resource/chef_client.rb +9 -9
- data/lib/chef/resource/chef_container.rb +9 -9
- data/lib/chef/resource/chef_data_bag.rb +9 -9
- data/lib/chef/resource/chef_data_bag_item.rb +27 -27
- data/lib/chef/resource/chef_environment.rb +21 -22
- data/lib/chef/resource/chef_group.rb +19 -19
- data/lib/chef/resource/chef_mirror.rb +32 -17
- data/lib/chef/resource/chef_node.rb +14 -14
- data/lib/chef/resource/chef_organization.rb +29 -30
- data/lib/chef/resource/chef_resolved_cookbooks.rb +7 -7
- data/lib/chef/resource/chef_role.rb +25 -22
- data/lib/chef/resource/chef_user.rb +13 -14
- data/lib/chef/resource/private_key.rb +24 -25
- data/lib/chef/resource/public_key.rb +6 -7
- data/lib/cheffish.rb +17 -17
- data/lib/cheffish/array_property.rb +2 -2
- data/lib/cheffish/base_properties.rb +3 -3
- data/lib/cheffish/base_resource.rb +8 -8
- data/lib/cheffish/basic_chef_client.rb +17 -17
- data/lib/cheffish/chef_actor_base.rb +8 -8
- data/lib/cheffish/chef_run.rb +7 -2
- data/lib/cheffish/chef_run_data.rb +2 -2
- data/lib/cheffish/chef_run_listener.rb +1 -1
- data/lib/cheffish/key_formatter.rb +16 -18
- data/lib/cheffish/merged_config.rb +5 -3
- data/lib/cheffish/node_properties.rb +11 -7
- data/lib/cheffish/recipe_dsl.rb +33 -34
- data/lib/cheffish/rspec.rb +3 -3
- data/lib/cheffish/rspec/chef_run_support.rb +13 -13
- data/lib/cheffish/rspec/matchers.rb +4 -4
- data/lib/cheffish/rspec/matchers/be_idempotent.rb +3 -3
- data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +3 -3
- data/lib/cheffish/rspec/matchers/have_updated.rb +3 -3
- data/lib/cheffish/rspec/recipe_run_wrapper.rb +8 -7
- data/lib/cheffish/rspec/repository_support.rb +6 -6
- data/lib/cheffish/server_api.rb +11 -11
- data/lib/cheffish/version.rb +1 -1
- data/spec/functional/fingerprint_spec.rb +12 -12
- data/spec/functional/merged_config_spec.rb +46 -6
- data/spec/functional/server_api_spec.rb +3 -3
- data/spec/integration/chef_acl_spec.rb +489 -489
- data/spec/integration/chef_client_spec.rb +39 -39
- data/spec/integration/chef_container_spec.rb +14 -14
- data/spec/integration/chef_data_bag_item_spec.rb +9 -9
- data/spec/integration/chef_group_spec.rb +219 -219
- data/spec/integration/chef_mirror_spec.rb +228 -228
- data/spec/integration/chef_node_spec.rb +511 -511
- data/spec/integration/chef_organization_spec.rb +126 -126
- data/spec/integration/chef_role_spec.rb +33 -33
- data/spec/integration/chef_user_spec.rb +37 -37
- data/spec/integration/private_key_spec.rb +154 -154
- data/spec/integration/recipe_dsl_spec.rb +10 -10
- data/spec/integration/rspec/converge_spec.rb +49 -49
- data/spec/support/key_support.rb +6 -6
- data/spec/support/spec_support.rb +3 -3
- data/spec/unit/get_private_key_spec.rb +19 -19
- data/spec/unit/recipe_run_wrapper_spec.rb +4 -4
- metadata +3 -3
@@ -1,29 +1,29 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "support/spec_support"
|
2
|
+
require "cheffish/rspec/chef_run_support"
|
3
3
|
|
4
4
|
describe Chef::Resource::ChefNode do
|
5
5
|
extend Cheffish::RSpec::ChefRunSupport
|
6
6
|
|
7
|
-
when_the_chef_12_server
|
8
|
-
organization
|
7
|
+
when_the_chef_12_server "is in multi-org mode" do
|
8
|
+
organization "foo"
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url,
|
11
|
+
Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
|
12
12
|
end
|
13
13
|
|
14
|
-
context
|
14
|
+
context "and is empty" do
|
15
15
|
context 'and we run a recipe that creates node "blah"' do
|
16
|
-
it
|
17
|
-
expect_recipe
|
18
|
-
chef_node
|
19
|
-
|
20
|
-
expect(get(
|
16
|
+
it "the node gets created" do
|
17
|
+
expect_recipe do
|
18
|
+
chef_node "blah"
|
19
|
+
end.to have_updated "chef_node[blah]", :create
|
20
|
+
expect(get("nodes/blah")["name"]).to eq("blah")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
# TODO why-run mode
|
25
25
|
|
26
|
-
context
|
26
|
+
context "and another chef server is running on port 8899" do
|
27
27
|
before :each do
|
28
28
|
@server = ChefZero::Server.new(:port => 8899)
|
29
29
|
@server.start_background
|
@@ -35,732 +35,732 @@ describe Chef::Resource::ChefNode do
|
|
35
35
|
|
36
36
|
context 'and a recipe is run that creates node "blah" on the second chef server using with_chef_server' do
|
37
37
|
|
38
|
-
it
|
39
|
-
expect_recipe
|
40
|
-
with_chef_server
|
41
|
-
chef_node
|
42
|
-
|
43
|
-
expect { get(
|
44
|
-
expect(get(
|
38
|
+
it "the node is created on the second chef server but not the first" do
|
39
|
+
expect_recipe do
|
40
|
+
with_chef_server "http://127.0.0.1:8899"
|
41
|
+
chef_node "blah"
|
42
|
+
end.to have_updated "chef_node[blah]", :create
|
43
|
+
expect { get("nodes/blah") }.to raise_error(Net::HTTPServerException)
|
44
|
+
expect(get("http://127.0.0.1:8899/nodes/blah")["name"]).to eq("blah")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'and a recipe is run that creates node "blah" on the second chef server using chef_server' do
|
49
49
|
|
50
|
-
it
|
51
|
-
expect_recipe
|
52
|
-
chef_node
|
53
|
-
chef_server({ :chef_server_url =>
|
50
|
+
it "the node is created on the second chef server but not the first" do
|
51
|
+
expect_recipe do
|
52
|
+
chef_node "blah" do
|
53
|
+
chef_server({ :chef_server_url => "http://127.0.0.1:8899" })
|
54
54
|
end
|
55
|
-
|
56
|
-
expect { get(
|
57
|
-
expect(get(
|
55
|
+
end.to have_updated "chef_node[blah]", :create
|
56
|
+
expect { get("nodes/blah") }.to raise_error(Net::HTTPServerException)
|
57
|
+
expect(get("http://127.0.0.1:8899/nodes/blah")["name"]).to eq("blah")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'and has a node named "blah"' do
|
64
|
-
node
|
64
|
+
node "blah", {}
|
65
65
|
|
66
66
|
it 'chef_node "blah" does not get created or updated' do
|
67
|
-
expect_recipe
|
68
|
-
chef_node
|
69
|
-
|
67
|
+
expect_recipe do
|
68
|
+
chef_node "blah"
|
69
|
+
end.not_to have_updated "chef_node[blah]", :create
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
context 'and has a node named "blah" with tags' do
|
74
|
-
node
|
75
|
-
|
74
|
+
node "blah", {
|
75
|
+
"normal" => { "tags" => %w{a b} },
|
76
76
|
}
|
77
77
|
|
78
78
|
context 'with chef_node "blah" that sets attributes' do
|
79
79
|
with_converge do
|
80
|
-
chef_node
|
80
|
+
chef_node "blah" do
|
81
81
|
attributes({})
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
86
|
-
expect(get(
|
85
|
+
it "the tags in attributes are used" do
|
86
|
+
expect(get("nodes/blah")["normal"]["tags"]).to eq(%w{a b})
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
context 'with chef_node "blah" that sets attributes with tags in them' do
|
91
91
|
with_converge do
|
92
|
-
chef_node
|
93
|
-
attributes
|
92
|
+
chef_node "blah" do
|
93
|
+
attributes "tags" => %w{c d}
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
98
|
-
expect(get(
|
97
|
+
it "the tags in attributes are used" do
|
98
|
+
expect(get("nodes/blah")["normal"]["tags"]).to eq(%w{c d})
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
describe
|
103
|
+
describe "#complete" do
|
104
104
|
context 'when the Chef server has a node named "blah" with everything in it' do
|
105
|
-
node
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
105
|
+
node "blah", {
|
106
|
+
"chef_environment" => "blah",
|
107
|
+
"run_list" => [ "recipe[bjork]" ],
|
108
|
+
"normal" => { "foo" => "bar", "tags" => %w{a b} },
|
109
|
+
"default" => { "foo2" => "bar2" },
|
110
|
+
"automatic" => { "foo3" => "bar3" },
|
111
|
+
"override" => { "foo4" => "bar4" },
|
112
112
|
}
|
113
113
|
|
114
|
-
it
|
115
|
-
expect_recipe
|
116
|
-
chef_node
|
117
|
-
|
118
|
-
expect(get(
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
114
|
+
it "chef_node with no attributes modifies nothing" do
|
115
|
+
expect_recipe do
|
116
|
+
chef_node "blah"
|
117
|
+
end.to be_up_to_date
|
118
|
+
expect(get("nodes/blah")).to include(
|
119
|
+
"name" => "blah",
|
120
|
+
"chef_environment" => "blah",
|
121
|
+
"run_list" => [ "recipe[bjork]" ],
|
122
|
+
"normal" => { "foo" => "bar", "tags" => %w{a b} },
|
123
|
+
"default" => { "foo2" => "bar2" },
|
124
|
+
"automatic" => { "foo3" => "bar3" },
|
125
|
+
"override" => { "foo4" => "bar4" }
|
126
126
|
)
|
127
127
|
end
|
128
128
|
|
129
|
-
it
|
130
|
-
expect_recipe
|
131
|
-
chef_node
|
129
|
+
it "chef_node with complete true removes everything except default, automatic and override" do
|
130
|
+
expect_recipe do
|
131
|
+
chef_node "blah" do
|
132
132
|
complete true
|
133
133
|
end
|
134
|
-
|
135
|
-
expect(get(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
134
|
+
end.to be_updated
|
135
|
+
expect(get("nodes/blah")).to include(
|
136
|
+
"name" => "blah",
|
137
|
+
"chef_environment" => "_default",
|
138
|
+
"run_list" => [ ],
|
139
|
+
"normal" => { "tags" => %w{a b} },
|
140
|
+
"default" => { "foo2" => "bar2" },
|
141
|
+
"automatic" => { "foo3" => "bar3" },
|
142
|
+
"override" => { "foo4" => "bar4" }
|
143
143
|
)
|
144
144
|
end
|
145
145
|
|
146
|
-
it
|
147
|
-
expect_recipe
|
148
|
-
chef_node
|
149
|
-
chef_environment
|
150
|
-
run_list [
|
151
|
-
attributes
|
152
|
-
tags
|
146
|
+
it "chef_node with complete true sets the given attributes" do
|
147
|
+
expect_recipe do
|
148
|
+
chef_node "blah" do
|
149
|
+
chef_environment "x"
|
150
|
+
run_list [ "recipe[y]" ]
|
151
|
+
attributes "a" => "b"
|
152
|
+
tags "c", "d"
|
153
153
|
complete true
|
154
154
|
end
|
155
|
-
|
156
|
-
expect(get(
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
155
|
+
end.to be_updated
|
156
|
+
expect(get("nodes/blah")).to include(
|
157
|
+
"name" => "blah",
|
158
|
+
"chef_environment" => "x",
|
159
|
+
"run_list" => [ "recipe[y]" ],
|
160
|
+
"normal" => { "a" => "b", "tags" => %w{c d} },
|
161
|
+
"default" => { "foo2" => "bar2" },
|
162
|
+
"automatic" => { "foo3" => "bar3" },
|
163
|
+
"override" => { "foo4" => "bar4" }
|
164
164
|
)
|
165
165
|
end
|
166
166
|
|
167
|
-
it
|
168
|
-
expect_recipe
|
169
|
-
chef_node
|
170
|
-
chef_environment
|
171
|
-
recipe
|
172
|
-
attribute
|
173
|
-
tags
|
167
|
+
it "chef_node with complete true and partial attributes sets the given attributes" do
|
168
|
+
expect_recipe do
|
169
|
+
chef_node "blah" do
|
170
|
+
chef_environment "x"
|
171
|
+
recipe "y"
|
172
|
+
attribute "a", "b"
|
173
|
+
tags "c", "d"
|
174
174
|
complete true
|
175
175
|
end
|
176
|
-
|
177
|
-
expect(get(
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
176
|
+
end.to be_updated
|
177
|
+
expect(get("nodes/blah")).to include(
|
178
|
+
"name" => "blah",
|
179
|
+
"chef_environment" => "x",
|
180
|
+
"run_list" => [ "recipe[y]" ],
|
181
|
+
"normal" => { "a" => "b", "tags" => %w{c d} },
|
182
|
+
"default" => { "foo2" => "bar2" },
|
183
|
+
"automatic" => { "foo3" => "bar3" },
|
184
|
+
"override" => { "foo4" => "bar4" }
|
185
185
|
)
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
-
describe
|
191
|
-
context
|
192
|
-
node
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
190
|
+
describe "#attributes" do
|
191
|
+
context "with a node with normal attributes a => b and c => { d => e }" do
|
192
|
+
node "blah", {
|
193
|
+
"normal" => {
|
194
|
+
"a" => "b",
|
195
|
+
"c" => { "d" => "e" },
|
196
|
+
"tags" => %w{a b},
|
197
197
|
},
|
198
|
-
|
199
|
-
|
198
|
+
"automatic" => {
|
199
|
+
"x" => "y",
|
200
200
|
},
|
201
|
-
|
201
|
+
"chef_environment" => "desert",
|
202
202
|
}
|
203
203
|
|
204
|
-
it
|
205
|
-
expect_recipe
|
206
|
-
chef_node
|
204
|
+
it "chef_node with attributes {} removes all normal attributes but leaves tags, automatic and environment alone" do
|
205
|
+
expect_recipe do
|
206
|
+
chef_node "blah" do
|
207
207
|
attributes({})
|
208
208
|
end
|
209
|
-
|
210
|
-
expect(get(
|
211
|
-
|
212
|
-
|
213
|
-
|
209
|
+
end.to have_updated("chef_node[blah]", :create)
|
210
|
+
expect(get("nodes/blah")).to include(
|
211
|
+
"normal" => { "tags" => %w{a b} },
|
212
|
+
"automatic" => { "x" => "y" },
|
213
|
+
"chef_environment" => "desert"
|
214
214
|
)
|
215
215
|
end
|
216
216
|
|
217
|
-
it
|
218
|
-
expect_recipe
|
219
|
-
chef_node
|
220
|
-
attributes
|
217
|
+
it "chef_node with attributes { c => d } replaces normal but not tags/automatic/environment" do
|
218
|
+
expect_recipe do
|
219
|
+
chef_node "blah" do
|
220
|
+
attributes "c" => "d"
|
221
221
|
end
|
222
|
-
|
223
|
-
expect(get(
|
224
|
-
|
225
|
-
|
226
|
-
|
222
|
+
end.to have_updated("chef_node[blah]", :create)
|
223
|
+
expect(get("nodes/blah")).to include(
|
224
|
+
"normal" => { "c" => "d", "tags" => %w{a b} },
|
225
|
+
"automatic" => { "x" => "y" },
|
226
|
+
"chef_environment" => "desert"
|
227
227
|
)
|
228
228
|
end
|
229
229
|
|
230
|
-
it
|
231
|
-
expect_recipe
|
232
|
-
chef_node
|
233
|
-
attributes
|
230
|
+
it "chef_node with attributes { c => f => g, y => z } replaces normal but not tags/automatic/environment" do
|
231
|
+
expect_recipe do
|
232
|
+
chef_node "blah" do
|
233
|
+
attributes "c" => { "f" => "g" }, "y" => "z"
|
234
234
|
end
|
235
|
-
|
236
|
-
expect(get(
|
237
|
-
|
238
|
-
|
239
|
-
|
235
|
+
end.to have_updated("chef_node[blah]", :create)
|
236
|
+
expect(get("nodes/blah")).to include(
|
237
|
+
"normal" => { "c" => { "f" => "g" }, "y" => "z", "tags" => %w{a b} },
|
238
|
+
"automatic" => { "x" => "y" },
|
239
|
+
"chef_environment" => "desert"
|
240
240
|
)
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'chef_node with attributes { tags => [ "x" ] } replaces normal and tags but not automatic/environment' do
|
244
|
-
expect_recipe
|
245
|
-
chef_node
|
246
|
-
attributes
|
244
|
+
expect_recipe do
|
245
|
+
chef_node "blah" do
|
246
|
+
attributes "tags" => [ "x" ]
|
247
247
|
end
|
248
|
-
|
249
|
-
expect(get(
|
250
|
-
|
251
|
-
|
252
|
-
|
248
|
+
end.to have_updated("chef_node[blah]", :create)
|
249
|
+
expect(get("nodes/blah")).to include(
|
250
|
+
"normal" => { "tags" => [ "x" ] },
|
251
|
+
"automatic" => { "x" => "y" },
|
252
|
+
"chef_environment" => "desert"
|
253
253
|
)
|
254
254
|
end
|
255
255
|
|
256
256
|
it 'chef_node with tags "x" and attributes { "tags" => [ "y" ] } sets tags to "x"' do
|
257
|
-
expect_recipe
|
258
|
-
chef_node
|
259
|
-
tags
|
260
|
-
attributes
|
257
|
+
expect_recipe do
|
258
|
+
chef_node "blah" do
|
259
|
+
tags "x"
|
260
|
+
attributes "tags" => [ "y" ]
|
261
261
|
end
|
262
|
-
|
263
|
-
expect(get(
|
264
|
-
|
265
|
-
|
262
|
+
end.to have_updated("chef_node[blah]", :create)
|
263
|
+
expect(get("nodes/blah")).to include(
|
264
|
+
"normal" => {
|
265
|
+
"tags" => [ "x" ],
|
266
266
|
},
|
267
|
-
|
268
|
-
|
267
|
+
"automatic" => { "x" => "y" },
|
268
|
+
"chef_environment" => "desert"
|
269
269
|
)
|
270
270
|
end
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
describe
|
275
|
-
context
|
276
|
-
node
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
274
|
+
describe "#attribute" do
|
275
|
+
context "with a node with normal attributes a => b and c => { d => e }" do
|
276
|
+
node "blah", {
|
277
|
+
"normal" => {
|
278
|
+
"a" => "b",
|
279
|
+
"c" => { "d" => "e" },
|
280
|
+
"tags" => %w{a b},
|
281
281
|
},
|
282
|
-
|
283
|
-
|
282
|
+
"automatic" => {
|
283
|
+
"x" => "y",
|
284
284
|
},
|
285
|
-
|
285
|
+
"chef_environment" => "desert",
|
286
286
|
}
|
287
287
|
|
288
|
-
context
|
289
|
-
it
|
290
|
-
expect_recipe
|
291
|
-
chef_node
|
292
|
-
|
293
|
-
expect(get(
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
288
|
+
context "basic scenarios" do
|
289
|
+
it "chef_node with no attributes, leaves it alone" do
|
290
|
+
expect_recipe do
|
291
|
+
chef_node "blah"
|
292
|
+
end.not_to have_updated("chef_node[blah]", :create)
|
293
|
+
expect(get("nodes/blah")).to include(
|
294
|
+
"normal" => {
|
295
|
+
"a" => "b",
|
296
|
+
"c" => { "d" => "e" },
|
297
|
+
"tags" => %w{a b},
|
298
298
|
},
|
299
|
-
|
300
|
-
|
299
|
+
"automatic" => { "x" => "y" },
|
300
|
+
"chef_environment" => "desert"
|
301
301
|
)
|
302
302
|
end
|
303
303
|
|
304
|
-
it
|
305
|
-
expect_recipe
|
306
|
-
chef_node
|
307
|
-
attribute
|
304
|
+
it "chef_node with attribute d, e adds the attribute" do
|
305
|
+
expect_recipe do
|
306
|
+
chef_node "blah" do
|
307
|
+
attribute "d", "e"
|
308
308
|
end
|
309
|
-
|
310
|
-
expect(get(
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
309
|
+
end.to have_updated("chef_node[blah]", :create)
|
310
|
+
expect(get("nodes/blah")).to include(
|
311
|
+
"normal" => {
|
312
|
+
"a" => "b",
|
313
|
+
"c" => { "d" => "e" },
|
314
|
+
"d" => "e",
|
315
|
+
"tags" => %w{a b},
|
316
316
|
},
|
317
|
-
|
318
|
-
|
317
|
+
"automatic" => { "x" => "y" },
|
318
|
+
"chef_environment" => "desert"
|
319
319
|
)
|
320
320
|
end
|
321
321
|
|
322
322
|
it 'chef_node with attribute tags, [ "x" ] replaces tags' do
|
323
|
-
expect_recipe
|
324
|
-
chef_node
|
325
|
-
attribute
|
323
|
+
expect_recipe do
|
324
|
+
chef_node "blah" do
|
325
|
+
attribute "tags", [ "x" ]
|
326
326
|
end
|
327
|
-
|
328
|
-
expect(get(
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
327
|
+
end.to have_updated("chef_node[blah]", :create)
|
328
|
+
expect(get("nodes/blah")).to include(
|
329
|
+
"normal" => {
|
330
|
+
"a" => "b",
|
331
|
+
"c" => { "d" => "e" },
|
332
|
+
"tags" => [ "x" ],
|
333
333
|
},
|
334
|
-
|
335
|
-
|
334
|
+
"automatic" => { "x" => "y" },
|
335
|
+
"chef_environment" => "desert"
|
336
336
|
)
|
337
337
|
end
|
338
338
|
|
339
|
-
it
|
340
|
-
expect_recipe
|
341
|
-
chef_node
|
342
|
-
attribute
|
339
|
+
it "chef_node with attribute c, x replaces the attribute" do
|
340
|
+
expect_recipe do
|
341
|
+
chef_node "blah" do
|
342
|
+
attribute "c", "x"
|
343
343
|
end
|
344
|
-
|
345
|
-
expect(get(
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
344
|
+
end.to have_updated("chef_node[blah]", :create)
|
345
|
+
expect(get("nodes/blah")).to include(
|
346
|
+
"normal" => {
|
347
|
+
"a" => "b",
|
348
|
+
"c" => "x",
|
349
|
+
"tags" => %w{a b},
|
350
350
|
},
|
351
|
-
|
352
|
-
|
351
|
+
"automatic" => { "x" => "y" },
|
352
|
+
"chef_environment" => "desert"
|
353
353
|
)
|
354
354
|
end
|
355
355
|
|
356
|
-
it
|
357
|
-
expect_recipe
|
358
|
-
chef_node
|
359
|
-
attribute
|
356
|
+
it "chef_node with attribute c, { d => x } replaces the attribute" do
|
357
|
+
expect_recipe do
|
358
|
+
chef_node "blah" do
|
359
|
+
attribute "c", { "d" => "x" }
|
360
360
|
end
|
361
|
-
|
362
|
-
expect(get(
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
361
|
+
end.to have_updated("chef_node[blah]", :create)
|
362
|
+
expect(get("nodes/blah")).to include(
|
363
|
+
"normal" => {
|
364
|
+
"a" => "b",
|
365
|
+
"c" => { "d" => "x" },
|
366
|
+
"tags" => %w{a b},
|
367
367
|
},
|
368
|
-
|
369
|
-
|
368
|
+
"automatic" => { "x" => "y" },
|
369
|
+
"chef_environment" => "desert"
|
370
370
|
)
|
371
371
|
end
|
372
372
|
|
373
|
-
it
|
374
|
-
expect_recipe
|
375
|
-
chef_node
|
376
|
-
attribute
|
373
|
+
it "chef_node with attribute [ c, d ], x replaces the attribute" do
|
374
|
+
expect_recipe do
|
375
|
+
chef_node "blah" do
|
376
|
+
attribute %w{c d}, "x"
|
377
377
|
end
|
378
|
-
|
379
|
-
expect(get(
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
378
|
+
end.to have_updated("chef_node[blah]", :create)
|
379
|
+
expect(get("nodes/blah")).to include(
|
380
|
+
"normal" => {
|
381
|
+
"a" => "b",
|
382
|
+
"c" => { "d" => "x" },
|
383
|
+
"tags" => %w{a b},
|
384
384
|
},
|
385
|
-
|
386
|
-
|
385
|
+
"automatic" => { "x" => "y" },
|
386
|
+
"chef_environment" => "desert"
|
387
387
|
)
|
388
388
|
end
|
389
389
|
|
390
|
-
it
|
391
|
-
expect
|
392
|
-
converge
|
393
|
-
chef_node
|
394
|
-
attribute
|
390
|
+
it "chef_node with attribute [ a, b ], x raises an error" do
|
391
|
+
expect do
|
392
|
+
converge do
|
393
|
+
chef_node "blah" do
|
394
|
+
attribute %w{a b}, "x"
|
395
395
|
end
|
396
|
-
|
397
|
-
|
396
|
+
end
|
397
|
+
end.to raise_error /Attempt to set \["a", "b"\] to x when \["a"\] is not a hash/
|
398
398
|
end
|
399
399
|
|
400
|
-
it
|
401
|
-
expect
|
402
|
-
converge
|
403
|
-
chef_node
|
404
|
-
attribute
|
400
|
+
it "chef_node with attribute [ a, b, c ], x raises an error" do
|
401
|
+
expect do
|
402
|
+
converge do
|
403
|
+
chef_node "blah" do
|
404
|
+
attribute %w{a b c}, "x"
|
405
405
|
end
|
406
|
-
|
407
|
-
|
406
|
+
end
|
407
|
+
end.to raise_error /Attempt to set \["a", "b", "c"\] to x when \["a"\] is not a hash/
|
408
408
|
end
|
409
409
|
|
410
|
-
it
|
411
|
-
expect_recipe
|
412
|
-
chef_node
|
413
|
-
attribute
|
410
|
+
it "chef_node with attribute [ x, y ], z adds a new attribute" do
|
411
|
+
expect_recipe do
|
412
|
+
chef_node "blah" do
|
413
|
+
attribute %w{x y}, "z"
|
414
414
|
end
|
415
|
-
|
416
|
-
expect(get(
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
415
|
+
end.to have_updated("chef_node[blah]", :create)
|
416
|
+
expect(get("nodes/blah")).to include(
|
417
|
+
"normal" => {
|
418
|
+
"a" => "b",
|
419
|
+
"c" => { "d" => "e" },
|
420
|
+
"x" => { "y" => "z" },
|
421
|
+
"tags" => %w{a b},
|
422
422
|
},
|
423
|
-
|
424
|
-
|
423
|
+
"automatic" => { "x" => "y" },
|
424
|
+
"chef_environment" => "desert"
|
425
425
|
)
|
426
426
|
end
|
427
427
|
|
428
|
-
it
|
429
|
-
expect_recipe
|
430
|
-
chef_node
|
428
|
+
it "chef_node with attribute [], {} clears all attributes" do
|
429
|
+
expect_recipe do
|
430
|
+
chef_node "blah" do
|
431
431
|
attribute([], {})
|
432
432
|
end
|
433
|
-
|
434
|
-
expect(get(
|
435
|
-
|
436
|
-
|
437
|
-
|
433
|
+
end.to have_updated("chef_node[blah]", :create)
|
434
|
+
expect(get("nodes/blah")).to include(
|
435
|
+
"normal" => {},
|
436
|
+
"automatic" => { "x" => "y" },
|
437
|
+
"chef_environment" => "desert"
|
438
438
|
)
|
439
439
|
end
|
440
440
|
end
|
441
441
|
|
442
|
-
context
|
443
|
-
it
|
444
|
-
expect_recipe
|
445
|
-
chef_node
|
446
|
-
attribute
|
442
|
+
context "delete" do
|
443
|
+
it "chef_node with attribute a, :delete deletes the attribute" do
|
444
|
+
expect_recipe do
|
445
|
+
chef_node "blah" do
|
446
|
+
attribute "a", :delete
|
447
447
|
end
|
448
|
-
|
449
|
-
expect(get(
|
450
|
-
|
451
|
-
|
452
|
-
|
448
|
+
end.to have_updated("chef_node[blah]", :create)
|
449
|
+
expect(get("nodes/blah")).to include(
|
450
|
+
"normal" => {
|
451
|
+
"c" => { "d" => "e" },
|
452
|
+
"tags" => %w{a b},
|
453
453
|
},
|
454
|
-
|
455
|
-
|
454
|
+
"automatic" => { "x" => "y" },
|
455
|
+
"chef_environment" => "desert"
|
456
456
|
)
|
457
457
|
end
|
458
458
|
|
459
|
-
it
|
460
|
-
expect_recipe
|
461
|
-
chef_node
|
462
|
-
attribute
|
459
|
+
it "chef_node with attribute c, :delete deletes the attribute" do
|
460
|
+
expect_recipe do
|
461
|
+
chef_node "blah" do
|
462
|
+
attribute "c", :delete
|
463
463
|
end
|
464
|
-
|
465
|
-
expect(get(
|
466
|
-
|
467
|
-
|
468
|
-
|
464
|
+
end.to have_updated("chef_node[blah]", :create)
|
465
|
+
expect(get("nodes/blah")).to include(
|
466
|
+
"normal" => {
|
467
|
+
"a" => "b",
|
468
|
+
"tags" => %w{a b},
|
469
469
|
},
|
470
|
-
|
471
|
-
|
470
|
+
"automatic" => { "x" => "y" },
|
471
|
+
"chef_environment" => "desert"
|
472
472
|
)
|
473
473
|
end
|
474
474
|
|
475
|
-
it
|
476
|
-
expect_recipe
|
477
|
-
chef_node
|
478
|
-
attribute
|
475
|
+
it "chef_node with attribute [ c, d ], :delete deletes the attribute" do
|
476
|
+
expect_recipe do
|
477
|
+
chef_node "blah" do
|
478
|
+
attribute %w{c d}, :delete
|
479
479
|
end
|
480
|
-
|
481
|
-
expect(get(
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
480
|
+
end.to have_updated("chef_node[blah]", :create)
|
481
|
+
expect(get("nodes/blah")).to include(
|
482
|
+
"normal" => {
|
483
|
+
"a" => "b",
|
484
|
+
"c" => {},
|
485
|
+
"tags" => %w{a b},
|
486
486
|
},
|
487
|
-
|
488
|
-
|
487
|
+
"automatic" => { "x" => "y" },
|
488
|
+
"chef_environment" => "desert"
|
489
489
|
)
|
490
490
|
end
|
491
491
|
|
492
|
-
it
|
493
|
-
expect_recipe
|
494
|
-
chef_node
|
495
|
-
attribute
|
492
|
+
it "chef_node with attribute xyz, :delete does nothing" do
|
493
|
+
expect_recipe do
|
494
|
+
chef_node "blah" do
|
495
|
+
attribute "xyz", :delete
|
496
496
|
end
|
497
|
-
|
498
|
-
expect(get(
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
497
|
+
end.not_to have_updated("chef_node[blah]", :create)
|
498
|
+
expect(get("nodes/blah")).to include(
|
499
|
+
"normal" => {
|
500
|
+
"a" => "b",
|
501
|
+
"c" => { "d" => "e" },
|
502
|
+
"tags" => %w{a b},
|
503
503
|
},
|
504
|
-
|
505
|
-
|
504
|
+
"automatic" => { "x" => "y" },
|
505
|
+
"chef_environment" => "desert"
|
506
506
|
)
|
507
507
|
end
|
508
508
|
|
509
|
-
it
|
510
|
-
expect_recipe
|
511
|
-
chef_node
|
512
|
-
attribute
|
509
|
+
it "chef_node with attribute [ c, x ], :delete does nothing" do
|
510
|
+
expect_recipe do
|
511
|
+
chef_node "blah" do
|
512
|
+
attribute %w{c x}, :delete
|
513
513
|
end
|
514
|
-
|
515
|
-
expect(get(
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
514
|
+
end.not_to have_updated("chef_node[blah]", :create)
|
515
|
+
expect(get("nodes/blah")).to include(
|
516
|
+
"normal" => {
|
517
|
+
"a" => "b",
|
518
|
+
"c" => { "d" => "e" },
|
519
|
+
"tags" => %w{a b},
|
520
520
|
},
|
521
|
-
|
522
|
-
|
521
|
+
"automatic" => { "x" => "y" },
|
522
|
+
"chef_environment" => "desert"
|
523
523
|
)
|
524
524
|
end
|
525
525
|
end
|
526
526
|
|
527
|
-
context
|
528
|
-
it
|
529
|
-
expect_recipe
|
530
|
-
chef_node
|
531
|
-
attribute
|
527
|
+
context "types" do
|
528
|
+
it "chef_node with attribute a, true sets a to true" do
|
529
|
+
expect_recipe do
|
530
|
+
chef_node "blah" do
|
531
|
+
attribute "a", true
|
532
532
|
end
|
533
|
-
|
534
|
-
expect(get(
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
533
|
+
end.to be_updated
|
534
|
+
expect(get("nodes/blah")).to include(
|
535
|
+
"normal" => {
|
536
|
+
"a" => true,
|
537
|
+
"c" => { "d" => "e" },
|
538
|
+
"tags" => %w{a b},
|
539
539
|
},
|
540
|
-
|
541
|
-
|
540
|
+
"automatic" => { "x" => "y" },
|
541
|
+
"chef_environment" => "desert"
|
542
542
|
)
|
543
543
|
end
|
544
544
|
|
545
|
-
it
|
546
|
-
expect_recipe
|
547
|
-
chef_node
|
548
|
-
attribute
|
545
|
+
it "chef_node with attribute a, 1 sets a to 1" do
|
546
|
+
expect_recipe do
|
547
|
+
chef_node "blah" do
|
548
|
+
attribute "a", 1
|
549
549
|
end
|
550
|
-
|
551
|
-
expect(get(
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
550
|
+
end.to be_updated
|
551
|
+
expect(get("nodes/blah")).to include(
|
552
|
+
"normal" => {
|
553
|
+
"a" => 1,
|
554
|
+
"c" => { "d" => "e" },
|
555
|
+
"tags" => %w{a b},
|
556
556
|
},
|
557
|
-
|
558
|
-
|
557
|
+
"automatic" => { "x" => "y" },
|
558
|
+
"chef_environment" => "desert"
|
559
559
|
)
|
560
560
|
end
|
561
561
|
|
562
562
|
it 'chef_node with attribute a, "1" sets a to "1"' do
|
563
|
-
expect_recipe
|
564
|
-
chef_node
|
565
|
-
attribute
|
563
|
+
expect_recipe do
|
564
|
+
chef_node "blah" do
|
565
|
+
attribute "a", "1"
|
566
566
|
end
|
567
|
-
|
568
|
-
expect(get(
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
567
|
+
end.to be_updated
|
568
|
+
expect(get("nodes/blah")).to include(
|
569
|
+
"normal" => {
|
570
|
+
"a" => "1",
|
571
|
+
"c" => { "d" => "e" },
|
572
|
+
"tags" => %w{a b},
|
573
573
|
},
|
574
|
-
|
575
|
-
|
574
|
+
"automatic" => { "x" => "y" },
|
575
|
+
"chef_environment" => "desert"
|
576
576
|
)
|
577
577
|
end
|
578
578
|
|
579
579
|
it 'chef_node with attribute a, "" sets a to ""' do
|
580
|
-
expect_recipe
|
581
|
-
chef_node
|
582
|
-
attribute
|
580
|
+
expect_recipe do
|
581
|
+
chef_node "blah" do
|
582
|
+
attribute "a", ""
|
583
583
|
end
|
584
|
-
|
585
|
-
expect(get(
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
584
|
+
end.to be_updated
|
585
|
+
expect(get("nodes/blah")).to include(
|
586
|
+
"normal" => {
|
587
|
+
"a" => "",
|
588
|
+
"c" => { "d" => "e" },
|
589
|
+
"tags" => %w{a b},
|
590
590
|
},
|
591
|
-
|
592
|
-
|
591
|
+
"automatic" => { "x" => "y" },
|
592
|
+
"chef_environment" => "desert"
|
593
593
|
)
|
594
594
|
end
|
595
595
|
|
596
|
-
it
|
597
|
-
expect_recipe
|
598
|
-
chef_node
|
599
|
-
attribute
|
596
|
+
it "chef_node with attribute a, nil sets a to nil" do
|
597
|
+
expect_recipe do
|
598
|
+
chef_node "blah" do
|
599
|
+
attribute "a", nil
|
600
600
|
end
|
601
|
-
|
602
|
-
expect(get(
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
601
|
+
end.to be_updated
|
602
|
+
expect(get("nodes/blah")).to include(
|
603
|
+
"normal" => {
|
604
|
+
"a" => nil,
|
605
|
+
"c" => { "d" => "e" },
|
606
|
+
"tags" => %w{a b},
|
607
607
|
},
|
608
|
-
|
609
|
-
|
608
|
+
"automatic" => { "x" => "y" },
|
609
|
+
"chef_environment" => "desert"
|
610
610
|
)
|
611
611
|
end
|
612
612
|
end
|
613
613
|
|
614
|
-
context
|
615
|
-
it
|
616
|
-
expect_recipe
|
617
|
-
chef_node
|
618
|
-
attribute
|
619
|
-
attribute
|
614
|
+
context "multiple attribute definitions" do
|
615
|
+
it "chef_node with attribute a, x and c, y replaces both attributes" do
|
616
|
+
expect_recipe do
|
617
|
+
chef_node "blah" do
|
618
|
+
attribute "a", "x"
|
619
|
+
attribute "c", "y"
|
620
620
|
end
|
621
|
-
|
622
|
-
expect(get(
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
621
|
+
end.to be_updated
|
622
|
+
expect(get("nodes/blah")).to include(
|
623
|
+
"normal" => {
|
624
|
+
"a" => "x",
|
625
|
+
"c" => "y",
|
626
|
+
"tags" => %w{a b},
|
627
627
|
},
|
628
|
-
|
629
|
-
|
628
|
+
"automatic" => { "x" => "y" },
|
629
|
+
"chef_environment" => "desert"
|
630
630
|
)
|
631
631
|
end
|
632
632
|
|
633
|
-
it
|
634
|
-
expect_recipe
|
635
|
-
chef_node
|
636
|
-
attribute
|
637
|
-
attribute
|
633
|
+
it "chef_node with attribute m, x and n, y adds both attributes" do
|
634
|
+
expect_recipe do
|
635
|
+
chef_node "blah" do
|
636
|
+
attribute "m", "x"
|
637
|
+
attribute "n", "y"
|
638
638
|
end
|
639
|
-
|
640
|
-
expect(get(
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
639
|
+
end.to be_updated
|
640
|
+
expect(get("nodes/blah")).to include(
|
641
|
+
"normal" => {
|
642
|
+
"a" => "b",
|
643
|
+
"c" => { "d" => "e" },
|
644
|
+
"m" => "x",
|
645
|
+
"n" => "y",
|
646
|
+
"tags" => %w{a b},
|
647
647
|
},
|
648
|
-
|
649
|
-
|
648
|
+
"automatic" => { "x" => "y" },
|
649
|
+
"chef_environment" => "desert"
|
650
650
|
)
|
651
651
|
end
|
652
652
|
|
653
|
-
it
|
654
|
-
expect_recipe
|
655
|
-
chef_node
|
656
|
-
attribute
|
657
|
-
attribute
|
653
|
+
it "chef_node with attribute [x, y], z and [x, yy], zz adds both attributes" do
|
654
|
+
expect_recipe do
|
655
|
+
chef_node "blah" do
|
656
|
+
attribute %w{x y}, "z"
|
657
|
+
attribute %w{x yy}, "zz"
|
658
658
|
end
|
659
|
-
|
660
|
-
expect(get(
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
659
|
+
end.to be_updated
|
660
|
+
expect(get("nodes/blah")).to include(
|
661
|
+
"normal" => {
|
662
|
+
"a" => "b",
|
663
|
+
"c" => { "d" => "e" },
|
664
|
+
"x" => {
|
665
|
+
"y" => "z",
|
666
|
+
"yy" => "zz",
|
667
667
|
},
|
668
|
-
|
668
|
+
"tags" => %w{a b},
|
669
669
|
},
|
670
|
-
|
671
|
-
|
670
|
+
"automatic" => { "x" => "y" },
|
671
|
+
"chef_environment" => "desert"
|
672
672
|
)
|
673
673
|
end
|
674
674
|
|
675
|
-
describe
|
676
|
-
it
|
677
|
-
expect_recipe
|
678
|
-
chef_node
|
679
|
-
attribute
|
680
|
-
attribute
|
675
|
+
describe "precedence" do
|
676
|
+
it "chef_node with attribute a, 1 and a, 2 sets a to 2" do
|
677
|
+
expect_recipe do
|
678
|
+
chef_node "blah" do
|
679
|
+
attribute "a", 1
|
680
|
+
attribute "a", 2
|
681
681
|
end
|
682
|
-
|
683
|
-
expect(get(
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
682
|
+
end.to be_updated
|
683
|
+
expect(get("nodes/blah")).to include(
|
684
|
+
"normal" => {
|
685
|
+
"a" => 2,
|
686
|
+
"c" => { "d" => "e" },
|
687
|
+
"tags" => %w{a b},
|
688
688
|
},
|
689
|
-
|
690
|
-
|
689
|
+
"automatic" => { "x" => "y" },
|
690
|
+
"chef_environment" => "desert"
|
691
691
|
)
|
692
692
|
end
|
693
693
|
|
694
|
-
it
|
695
|
-
expect_recipe
|
696
|
-
chef_node
|
697
|
-
attribute
|
698
|
-
attribute
|
694
|
+
it "chef_node with attribute [ x, y ], 1 and [ x, y ], 2 sets [ x, y ], 2" do
|
695
|
+
expect_recipe do
|
696
|
+
chef_node "blah" do
|
697
|
+
attribute %w{x y}, 1
|
698
|
+
attribute %w{x y}, 2
|
699
699
|
end
|
700
|
-
|
701
|
-
expect(get(
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
700
|
+
end.to be_updated
|
701
|
+
expect(get("nodes/blah")).to include(
|
702
|
+
"normal" => {
|
703
|
+
"a" => "b",
|
704
|
+
"c" => { "d" => "e" },
|
705
|
+
"x" => { "y" => 2 },
|
706
|
+
"tags" => %w{a b},
|
707
707
|
},
|
708
|
-
|
709
|
-
|
708
|
+
"automatic" => { "x" => "y" },
|
709
|
+
"chef_environment" => "desert"
|
710
710
|
)
|
711
711
|
end
|
712
712
|
|
713
|
-
it
|
714
|
-
expect_recipe
|
715
|
-
chef_node
|
716
|
-
attribute
|
717
|
-
attribute
|
713
|
+
it "chef_node with attribute [ c, e ], { a => 1 }, [ c, e ], { b => 2 } sets b only" do
|
714
|
+
expect_recipe do
|
715
|
+
chef_node "blah" do
|
716
|
+
attribute %w{c e}, { "a" => 1 }
|
717
|
+
attribute %w{c e}, { "b" => 2 }
|
718
718
|
end
|
719
|
-
|
720
|
-
expect(get(
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
719
|
+
end.to be_updated
|
720
|
+
expect(get("nodes/blah")).to include(
|
721
|
+
"normal" => {
|
722
|
+
"a" => "b",
|
723
|
+
"c" => { "d" => "e", "e" => { "b" => 2 } },
|
724
|
+
"tags" => %w{a b},
|
725
725
|
},
|
726
|
-
|
727
|
-
|
726
|
+
"automatic" => { "x" => "y" },
|
727
|
+
"chef_environment" => "desert"
|
728
728
|
)
|
729
729
|
end
|
730
730
|
|
731
|
-
it
|
732
|
-
expect_recipe
|
733
|
-
chef_node
|
734
|
-
attribute
|
735
|
-
attribute
|
731
|
+
it "chef_node with attribute [ c, e ], { a => 1 }, [ c, e, b ], 2 sets both" do
|
732
|
+
expect_recipe do
|
733
|
+
chef_node "blah" do
|
734
|
+
attribute %w{c e}, { "a" => 1 }
|
735
|
+
attribute %w{c e b}, 2
|
736
736
|
end
|
737
|
-
|
738
|
-
expect(get(
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
737
|
+
end.to be_updated
|
738
|
+
expect(get("nodes/blah")).to include(
|
739
|
+
"normal" => {
|
740
|
+
"a" => "b",
|
741
|
+
"c" => { "d" => "e", "e" => { "a" => 1, "b" => 2 } },
|
742
|
+
"tags" => %w{a b},
|
743
743
|
},
|
744
|
-
|
745
|
-
|
744
|
+
"automatic" => { "x" => "y" },
|
745
|
+
"chef_environment" => "desert"
|
746
746
|
)
|
747
747
|
end
|
748
748
|
|
749
|
-
it
|
750
|
-
expect_recipe
|
751
|
-
chef_node
|
752
|
-
attribute
|
753
|
-
attribute
|
749
|
+
it "chef_node with attribute [ c, e, b ], 2, [ c, e ], { a => 1 } sets a only" do
|
750
|
+
expect_recipe do
|
751
|
+
chef_node "blah" do
|
752
|
+
attribute %w{c e b}, 2
|
753
|
+
attribute %w{c e}, { "a" => 1 }
|
754
754
|
end
|
755
|
-
|
756
|
-
expect(get(
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
755
|
+
end.to be_updated
|
756
|
+
expect(get("nodes/blah")).to include(
|
757
|
+
"normal" => {
|
758
|
+
"a" => "b",
|
759
|
+
"c" => { "d" => "e", "e" => { "a" => 1 } },
|
760
|
+
"tags" => %w{a b},
|
761
761
|
},
|
762
|
-
|
763
|
-
|
762
|
+
"automatic" => { "x" => "y" },
|
763
|
+
"chef_environment" => "desert"
|
764
764
|
)
|
765
765
|
end
|
766
766
|
end
|
@@ -769,14 +769,14 @@ describe Chef::Resource::ChefNode do
|
|
769
769
|
end
|
770
770
|
end
|
771
771
|
|
772
|
-
when_the_chef_server
|
773
|
-
context
|
772
|
+
when_the_chef_server "is in OSC mode" do
|
773
|
+
context "and is empty" do
|
774
774
|
context 'and we run a recipe that creates node "blah"' do
|
775
|
-
it
|
776
|
-
expect_recipe
|
777
|
-
chef_node
|
778
|
-
|
779
|
-
expect(get(
|
775
|
+
it "the node gets created" do
|
776
|
+
expect_recipe do
|
777
|
+
chef_node "blah"
|
778
|
+
end.to have_updated "chef_node[blah]", :create
|
779
|
+
expect(get("nodes/blah")["name"]).to eq("blah")
|
780
780
|
end
|
781
781
|
end
|
782
782
|
end
|