cheffish 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -8
  3. data/Rakefile +24 -12
  4. data/cheffish.gemspec +15 -15
  5. data/lib/chef/resource/chef_acl.rb +63 -63
  6. data/lib/chef/resource/chef_client.rb +9 -9
  7. data/lib/chef/resource/chef_container.rb +9 -9
  8. data/lib/chef/resource/chef_data_bag.rb +9 -9
  9. data/lib/chef/resource/chef_data_bag_item.rb +27 -27
  10. data/lib/chef/resource/chef_environment.rb +21 -22
  11. data/lib/chef/resource/chef_group.rb +19 -19
  12. data/lib/chef/resource/chef_mirror.rb +32 -17
  13. data/lib/chef/resource/chef_node.rb +14 -14
  14. data/lib/chef/resource/chef_organization.rb +29 -30
  15. data/lib/chef/resource/chef_resolved_cookbooks.rb +7 -7
  16. data/lib/chef/resource/chef_role.rb +25 -22
  17. data/lib/chef/resource/chef_user.rb +13 -14
  18. data/lib/chef/resource/private_key.rb +24 -25
  19. data/lib/chef/resource/public_key.rb +6 -7
  20. data/lib/cheffish.rb +17 -17
  21. data/lib/cheffish/array_property.rb +2 -2
  22. data/lib/cheffish/base_properties.rb +3 -3
  23. data/lib/cheffish/base_resource.rb +8 -8
  24. data/lib/cheffish/basic_chef_client.rb +17 -17
  25. data/lib/cheffish/chef_actor_base.rb +8 -8
  26. data/lib/cheffish/chef_run.rb +7 -2
  27. data/lib/cheffish/chef_run_data.rb +2 -2
  28. data/lib/cheffish/chef_run_listener.rb +1 -1
  29. data/lib/cheffish/key_formatter.rb +16 -18
  30. data/lib/cheffish/merged_config.rb +5 -3
  31. data/lib/cheffish/node_properties.rb +11 -7
  32. data/lib/cheffish/recipe_dsl.rb +33 -34
  33. data/lib/cheffish/rspec.rb +3 -3
  34. data/lib/cheffish/rspec/chef_run_support.rb +13 -13
  35. data/lib/cheffish/rspec/matchers.rb +4 -4
  36. data/lib/cheffish/rspec/matchers/be_idempotent.rb +3 -3
  37. data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +3 -3
  38. data/lib/cheffish/rspec/matchers/have_updated.rb +3 -3
  39. data/lib/cheffish/rspec/recipe_run_wrapper.rb +8 -7
  40. data/lib/cheffish/rspec/repository_support.rb +6 -6
  41. data/lib/cheffish/server_api.rb +11 -11
  42. data/lib/cheffish/version.rb +1 -1
  43. data/spec/functional/fingerprint_spec.rb +12 -12
  44. data/spec/functional/merged_config_spec.rb +46 -6
  45. data/spec/functional/server_api_spec.rb +3 -3
  46. data/spec/integration/chef_acl_spec.rb +489 -489
  47. data/spec/integration/chef_client_spec.rb +39 -39
  48. data/spec/integration/chef_container_spec.rb +14 -14
  49. data/spec/integration/chef_data_bag_item_spec.rb +9 -9
  50. data/spec/integration/chef_group_spec.rb +219 -219
  51. data/spec/integration/chef_mirror_spec.rb +228 -228
  52. data/spec/integration/chef_node_spec.rb +511 -511
  53. data/spec/integration/chef_organization_spec.rb +126 -126
  54. data/spec/integration/chef_role_spec.rb +33 -33
  55. data/spec/integration/chef_user_spec.rb +37 -37
  56. data/spec/integration/private_key_spec.rb +154 -154
  57. data/spec/integration/recipe_dsl_spec.rb +10 -10
  58. data/spec/integration/rspec/converge_spec.rb +49 -49
  59. data/spec/support/key_support.rb +6 -6
  60. data/spec/support/spec_support.rb +3 -3
  61. data/spec/unit/get_private_key_spec.rb +19 -19
  62. data/spec/unit/recipe_run_wrapper_spec.rb +4 -4
  63. metadata +3 -3
@@ -1,29 +1,29 @@
1
- require 'support/spec_support'
2
- require 'cheffish/rspec/chef_run_support'
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 'is in multi-org mode' do
8
- organization 'foo'
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, '/organizations/foo').to_s
11
+ Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
12
12
  end
13
13
 
14
- context 'and is empty' do
14
+ context "and is empty" do
15
15
  context 'and we run a recipe that creates node "blah"' do
16
- it 'the node gets created' do
17
- expect_recipe {
18
- chef_node 'blah'
19
- }.to have_updated 'chef_node[blah]', :create
20
- expect(get('nodes/blah')['name']).to eq('blah')
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 'and another chef server is running on port 8899' do
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 'the node is created on the second chef server but not the first' do
39
- expect_recipe {
40
- with_chef_server 'http://127.0.0.1:8899'
41
- chef_node 'blah'
42
- }.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')
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 'the node is created on the second chef server but not the first' do
51
- expect_recipe {
52
- chef_node 'blah' do
53
- chef_server({ :chef_server_url => 'http://127.0.0.1:8899' })
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
- }.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')
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 'blah', {}
64
+ node "blah", {}
65
65
 
66
66
  it 'chef_node "blah" does not get created or updated' do
67
- expect_recipe {
68
- chef_node 'blah'
69
- }.not_to have_updated 'chef_node[blah]', :create
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 'blah', {
75
- 'normal' => { 'tags' => [ 'a', 'b' ] }
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 'blah' do
80
+ chef_node "blah" do
81
81
  attributes({})
82
82
  end
83
83
  end
84
84
 
85
- it 'the tags in attributes are used' do
86
- expect(get('nodes/blah')['normal']['tags']).to eq([ 'a', 'b' ])
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 'blah' do
93
- attributes 'tags' => [ 'c', 'd' ]
92
+ chef_node "blah" do
93
+ attributes "tags" => %w{c d}
94
94
  end
95
95
  end
96
96
 
97
- it 'the tags in attributes are used' do
98
- expect(get('nodes/blah')['normal']['tags']).to eq([ 'c', 'd' ])
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 '#complete' do
103
+ describe "#complete" do
104
104
  context 'when the Chef server has a node named "blah" with everything in it' do
105
- node 'blah', {
106
- 'chef_environment' => 'blah',
107
- 'run_list' => [ 'recipe[bjork]' ],
108
- 'normal' => { 'foo' => 'bar', 'tags' => [ 'a', 'b' ] },
109
- 'default' => { 'foo2' => 'bar2' },
110
- 'automatic' => { 'foo3' => 'bar3' },
111
- 'override' => { 'foo4' => 'bar4' }
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 'chef_node with no attributes modifies nothing' do
115
- expect_recipe {
116
- chef_node 'blah'
117
- }.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' => [ 'a', 'b' ] },
123
- 'default' => { 'foo2' => 'bar2' },
124
- 'automatic' => { 'foo3' => 'bar3' },
125
- 'override' => { 'foo4' => 'bar4' }
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 'chef_node with complete true removes everything except default, automatic and override' do
130
- expect_recipe {
131
- chef_node 'blah' do
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
- }.to be_updated
135
- expect(get('nodes/blah')).to include(
136
- 'name' => 'blah',
137
- 'chef_environment' => '_default',
138
- 'run_list' => [ ],
139
- 'normal' => { 'tags' => [ 'a', 'b' ] },
140
- 'default' => { 'foo2' => 'bar2' },
141
- 'automatic' => { 'foo3' => 'bar3' },
142
- 'override' => { 'foo4' => 'bar4' }
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 'chef_node with complete true sets the given attributes' do
147
- expect_recipe {
148
- chef_node 'blah' do
149
- chef_environment 'x'
150
- run_list [ 'recipe[y]' ]
151
- attributes 'a' => 'b'
152
- tags 'c', 'd'
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
- }.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' => [ 'c', 'd' ] },
161
- 'default' => { 'foo2' => 'bar2' },
162
- 'automatic' => { 'foo3' => 'bar3' },
163
- 'override' => { 'foo4' => 'bar4' }
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 'chef_node with complete true and partial attributes sets the given attributes' do
168
- expect_recipe {
169
- chef_node 'blah' do
170
- chef_environment 'x'
171
- recipe 'y'
172
- attribute 'a', 'b'
173
- tags 'c', 'd'
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
- }.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' => [ 'c', 'd' ] },
182
- 'default' => { 'foo2' => 'bar2' },
183
- 'automatic' => { 'foo3' => 'bar3' },
184
- 'override' => { 'foo4' => 'bar4' }
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 '#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' => [ 'a', 'b' ]
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
- 'automatic' => {
199
- 'x' => 'y'
198
+ "automatic" => {
199
+ "x" => "y",
200
200
  },
201
- 'chef_environment' => 'desert'
201
+ "chef_environment" => "desert",
202
202
  }
203
203
 
204
- it 'chef_node with attributes {} removes all normal attributes but leaves tags, automatic and environment alone' do
205
- expect_recipe {
206
- chef_node 'blah' do
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
- }.to have_updated('chef_node[blah]', :create)
210
- expect(get('nodes/blah')).to include(
211
- 'normal' => { 'tags' => [ 'a', 'b' ] },
212
- 'automatic' => { 'x' => 'y' },
213
- 'chef_environment' => 'desert'
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 'chef_node with attributes { c => d } replaces normal but not tags/automatic/environment' do
218
- expect_recipe {
219
- chef_node 'blah' do
220
- attributes 'c' => 'd'
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
- }.to have_updated('chef_node[blah]', :create)
223
- expect(get('nodes/blah')).to include(
224
- 'normal' => { 'c' => 'd', 'tags' => [ 'a', 'b' ] },
225
- 'automatic' => { 'x' => 'y' },
226
- 'chef_environment' => 'desert'
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 'chef_node with attributes { c => f => g, y => z } replaces normal but not tags/automatic/environment' do
231
- expect_recipe {
232
- chef_node 'blah' do
233
- attributes 'c' => { 'f' => 'g' }, 'y' => 'z'
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
- }.to have_updated('chef_node[blah]', :create)
236
- expect(get('nodes/blah')).to include(
237
- 'normal' => { 'c' => { 'f' => 'g' }, 'y' => 'z', 'tags' => [ 'a', 'b' ] },
238
- 'automatic' => { 'x' => 'y' },
239
- 'chef_environment' => 'desert'
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 'blah' do
246
- attributes 'tags' => [ 'x' ]
244
+ expect_recipe do
245
+ chef_node "blah" do
246
+ attributes "tags" => [ "x" ]
247
247
  end
248
- }.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'
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 'blah' do
259
- tags 'x'
260
- attributes 'tags' => [ 'y' ]
257
+ expect_recipe do
258
+ chef_node "blah" do
259
+ tags "x"
260
+ attributes "tags" => [ "y" ]
261
261
  end
262
- }.to have_updated('chef_node[blah]', :create)
263
- expect(get('nodes/blah')).to include(
264
- 'normal' => {
265
- 'tags' => [ 'x' ]
262
+ end.to have_updated("chef_node[blah]", :create)
263
+ expect(get("nodes/blah")).to include(
264
+ "normal" => {
265
+ "tags" => [ "x" ],
266
266
  },
267
- 'automatic' => { 'x' => 'y' },
268
- 'chef_environment' => 'desert'
267
+ "automatic" => { "x" => "y" },
268
+ "chef_environment" => "desert"
269
269
  )
270
270
  end
271
271
  end
272
272
  end
273
273
 
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' => [ 'a', 'b' ]
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
- 'automatic' => {
283
- 'x' => 'y'
282
+ "automatic" => {
283
+ "x" => "y",
284
284
  },
285
- 'chef_environment' => 'desert'
285
+ "chef_environment" => "desert",
286
286
  }
287
287
 
288
- context 'basic scenarios' do
289
- it 'chef_node with no attributes, leaves it alone' do
290
- expect_recipe {
291
- chef_node 'blah'
292
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
300
- 'chef_environment' => 'desert'
299
+ "automatic" => { "x" => "y" },
300
+ "chef_environment" => "desert"
301
301
  )
302
302
  end
303
303
 
304
- it 'chef_node with attribute d, e adds the attribute' do
305
- expect_recipe {
306
- chef_node 'blah' do
307
- attribute 'd', 'e'
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
318
- 'chef_environment' => 'desert'
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 'blah' do
325
- attribute 'tags', [ 'x' ]
323
+ expect_recipe do
324
+ chef_node "blah" do
325
+ attribute "tags", [ "x" ]
326
326
  end
327
- }.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' ]
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
- 'automatic' => { 'x' => 'y' },
335
- 'chef_environment' => 'desert'
334
+ "automatic" => { "x" => "y" },
335
+ "chef_environment" => "desert"
336
336
  )
337
337
  end
338
338
 
339
- it 'chef_node with attribute c, x replaces the attribute' do
340
- expect_recipe {
341
- chef_node 'blah' do
342
- attribute 'c', 'x'
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
- }.to have_updated('chef_node[blah]', :create)
345
- expect(get('nodes/blah')).to include(
346
- 'normal' => {
347
- 'a' => 'b',
348
- 'c' => 'x',
349
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
352
- 'chef_environment' => 'desert'
351
+ "automatic" => { "x" => "y" },
352
+ "chef_environment" => "desert"
353
353
  )
354
354
  end
355
355
 
356
- it 'chef_node with attribute c, { d => x } replaces the attribute' do
357
- expect_recipe {
358
- chef_node 'blah' do
359
- attribute 'c', { 'd' => 'x' }
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
369
- 'chef_environment' => 'desert'
368
+ "automatic" => { "x" => "y" },
369
+ "chef_environment" => "desert"
370
370
  )
371
371
  end
372
372
 
373
- it 'chef_node with attribute [ c, d ], x replaces the attribute' do
374
- expect_recipe {
375
- chef_node 'blah' do
376
- attribute [ 'c', 'd' ], 'x'
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
386
- 'chef_environment' => 'desert'
385
+ "automatic" => { "x" => "y" },
386
+ "chef_environment" => "desert"
387
387
  )
388
388
  end
389
389
 
390
- it 'chef_node with attribute [ a, b ], x raises an error' do
391
- expect {
392
- converge {
393
- chef_node 'blah' do
394
- attribute [ 'a', 'b' ], 'x'
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
- }.to raise_error /Attempt to set \["a", "b"\] to x when \["a"\] is not a hash/
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 'chef_node with attribute [ a, b, c ], x raises an error' do
401
- expect {
402
- converge {
403
- chef_node 'blah' do
404
- attribute [ 'a', 'b', 'c' ], 'x'
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
- }.to raise_error /Attempt to set \["a", "b", "c"\] to x when \["a"\] is not a hash/
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 'chef_node with attribute [ x, y ], z adds a new attribute' do
411
- expect_recipe {
412
- chef_node 'blah' do
413
- attribute [ 'x', 'y' ], 'z'
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
424
- 'chef_environment' => 'desert'
423
+ "automatic" => { "x" => "y" },
424
+ "chef_environment" => "desert"
425
425
  )
426
426
  end
427
427
 
428
- it 'chef_node with attribute [], {} clears all attributes' do
429
- expect_recipe {
430
- chef_node 'blah' do
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
- }.to have_updated('chef_node[blah]', :create)
434
- expect(get('nodes/blah')).to include(
435
- 'normal' => { },
436
- 'automatic' => { 'x' => 'y' },
437
- 'chef_environment' => 'desert'
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 'delete' do
443
- it 'chef_node with attribute a, :delete deletes the attribute' do
444
- expect_recipe {
445
- chef_node 'blah' do
446
- attribute 'a', :delete
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
- }.to have_updated('chef_node[blah]', :create)
449
- expect(get('nodes/blah')).to include(
450
- 'normal' => {
451
- 'c' => { 'd' => 'e' },
452
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
455
- 'chef_environment' => 'desert'
454
+ "automatic" => { "x" => "y" },
455
+ "chef_environment" => "desert"
456
456
  )
457
457
  end
458
458
 
459
- it 'chef_node with attribute c, :delete deletes the attribute' do
460
- expect_recipe {
461
- chef_node 'blah' do
462
- attribute 'c', :delete
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
- }.to have_updated('chef_node[blah]', :create)
465
- expect(get('nodes/blah')).to include(
466
- 'normal' => {
467
- 'a' => 'b',
468
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
471
- 'chef_environment' => 'desert'
470
+ "automatic" => { "x" => "y" },
471
+ "chef_environment" => "desert"
472
472
  )
473
473
  end
474
474
 
475
- it 'chef_node with attribute [ c, d ], :delete deletes the attribute' do
476
- expect_recipe {
477
- chef_node 'blah' do
478
- attribute [ 'c', 'd' ], :delete
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
- }.to have_updated('chef_node[blah]', :create)
481
- expect(get('nodes/blah')).to include(
482
- 'normal' => {
483
- 'a' => 'b',
484
- 'c' => {},
485
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
488
- 'chef_environment' => 'desert'
487
+ "automatic" => { "x" => "y" },
488
+ "chef_environment" => "desert"
489
489
  )
490
490
  end
491
491
 
492
- it 'chef_node with attribute xyz, :delete does nothing' do
493
- expect_recipe {
494
- chef_node 'blah' do
495
- attribute 'xyz', :delete
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
505
- 'chef_environment' => 'desert'
504
+ "automatic" => { "x" => "y" },
505
+ "chef_environment" => "desert"
506
506
  )
507
507
  end
508
508
 
509
- it 'chef_node with attribute [ c, x ], :delete does nothing' do
510
- expect_recipe {
511
- chef_node 'blah' do
512
- attribute [ 'c', 'x' ], :delete
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
522
- 'chef_environment' => 'desert'
521
+ "automatic" => { "x" => "y" },
522
+ "chef_environment" => "desert"
523
523
  )
524
524
  end
525
525
  end
526
526
 
527
- context 'types' do
528
- it 'chef_node with attribute a, true sets a to true' do
529
- expect_recipe {
530
- chef_node 'blah' do
531
- attribute 'a', true
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
- }.to be_updated
534
- expect(get('nodes/blah')).to include(
535
- 'normal' => {
536
- 'a' => true,
537
- 'c' => { 'd' => 'e' },
538
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
541
- 'chef_environment' => 'desert'
540
+ "automatic" => { "x" => "y" },
541
+ "chef_environment" => "desert"
542
542
  )
543
543
  end
544
544
 
545
- it 'chef_node with attribute a, 1 sets a to 1' do
546
- expect_recipe {
547
- chef_node 'blah' do
548
- attribute 'a', 1
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
- }.to be_updated
551
- expect(get('nodes/blah')).to include(
552
- 'normal' => {
553
- 'a' => 1,
554
- 'c' => { 'd' => 'e' },
555
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
558
- 'chef_environment' => 'desert'
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 'blah' do
565
- attribute 'a', "1"
563
+ expect_recipe do
564
+ chef_node "blah" do
565
+ attribute "a", "1"
566
566
  end
567
- }.to be_updated
568
- expect(get('nodes/blah')).to include(
569
- 'normal' => {
570
- 'a' => "1",
571
- 'c' => { 'd' => 'e' },
572
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
575
- 'chef_environment' => 'desert'
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 'blah' do
582
- attribute 'a', ""
580
+ expect_recipe do
581
+ chef_node "blah" do
582
+ attribute "a", ""
583
583
  end
584
- }.to be_updated
585
- expect(get('nodes/blah')).to include(
586
- 'normal' => {
587
- 'a' => "",
588
- 'c' => { 'd' => 'e' },
589
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
592
- 'chef_environment' => 'desert'
591
+ "automatic" => { "x" => "y" },
592
+ "chef_environment" => "desert"
593
593
  )
594
594
  end
595
595
 
596
- it 'chef_node with attribute a, nil sets a to nil' do
597
- expect_recipe {
598
- chef_node 'blah' do
599
- attribute 'a', nil
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
- }.to be_updated
602
- expect(get('nodes/blah')).to include(
603
- 'normal' => {
604
- 'a' => nil,
605
- 'c' => { 'd' => 'e' },
606
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
609
- 'chef_environment' => 'desert'
608
+ "automatic" => { "x" => "y" },
609
+ "chef_environment" => "desert"
610
610
  )
611
611
  end
612
612
  end
613
613
 
614
- context 'multiple attribute definitions' do
615
- it 'chef_node with attribute a, x and c, y replaces both attributes' do
616
- expect_recipe {
617
- chef_node 'blah' do
618
- attribute 'a', 'x'
619
- attribute 'c', 'y'
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
- }.to be_updated
622
- expect(get('nodes/blah')).to include(
623
- 'normal' => {
624
- 'a' => 'x',
625
- 'c' => 'y',
626
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
629
- 'chef_environment' => 'desert'
628
+ "automatic" => { "x" => "y" },
629
+ "chef_environment" => "desert"
630
630
  )
631
631
  end
632
632
 
633
- it 'chef_node with attribute m, x and n, y adds both attributes' do
634
- expect_recipe {
635
- chef_node 'blah' do
636
- attribute 'm', 'x'
637
- attribute 'n', 'y'
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
649
- 'chef_environment' => 'desert'
648
+ "automatic" => { "x" => "y" },
649
+ "chef_environment" => "desert"
650
650
  )
651
651
  end
652
652
 
653
- it 'chef_node with attribute [x, y], z and [x, yy], zz adds both attributes' do
654
- expect_recipe {
655
- chef_node 'blah' do
656
- attribute [ 'x', 'y' ], 'z'
657
- attribute [ 'x', 'yy' ], 'zz'
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
- }.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'
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
- 'tags' => [ 'a', 'b' ]
668
+ "tags" => %w{a b},
669
669
  },
670
- 'automatic' => { 'x' => 'y' },
671
- 'chef_environment' => 'desert'
670
+ "automatic" => { "x" => "y" },
671
+ "chef_environment" => "desert"
672
672
  )
673
673
  end
674
674
 
675
- describe 'precedence' do
676
- it 'chef_node with attribute a, 1 and a, 2 sets a to 2' do
677
- expect_recipe {
678
- chef_node 'blah' do
679
- attribute 'a', 1
680
- attribute 'a', 2
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
- }.to be_updated
683
- expect(get('nodes/blah')).to include(
684
- 'normal' => {
685
- 'a' => 2,
686
- 'c' => { 'd' => 'e' },
687
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
690
- 'chef_environment' => 'desert'
689
+ "automatic" => { "x" => "y" },
690
+ "chef_environment" => "desert"
691
691
  )
692
692
  end
693
693
 
694
- it 'chef_node with attribute [ x, y ], 1 and [ x, y ], 2 sets [ x, y ], 2' do
695
- expect_recipe {
696
- chef_node 'blah' do
697
- attribute [ 'x', 'y' ], 1
698
- attribute [ 'x', 'y' ], 2
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
709
- 'chef_environment' => 'desert'
708
+ "automatic" => { "x" => "y" },
709
+ "chef_environment" => "desert"
710
710
  )
711
711
  end
712
712
 
713
- it 'chef_node with attribute [ c, e ], { a => 1 }, [ c, e ], { b => 2 } sets b only' do
714
- expect_recipe {
715
- chef_node 'blah' do
716
- attribute [ 'c', 'e' ], { 'a' => 1 }
717
- attribute [ 'c', 'e' ], { 'b' => 2 }
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
- }.to be_updated
720
- expect(get('nodes/blah')).to include(
721
- 'normal' => {
722
- 'a' => 'b',
723
- 'c' => { 'd' => 'e', 'e' => { 'b' => 2 } },
724
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
727
- 'chef_environment' => 'desert'
726
+ "automatic" => { "x" => "y" },
727
+ "chef_environment" => "desert"
728
728
  )
729
729
  end
730
730
 
731
- it 'chef_node with attribute [ c, e ], { a => 1 }, [ c, e, b ], 2 sets both' do
732
- expect_recipe {
733
- chef_node 'blah' do
734
- attribute [ 'c', 'e' ], { 'a' => 1 }
735
- attribute [ 'c', 'e', 'b' ], 2
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
- }.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' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
745
- 'chef_environment' => 'desert'
744
+ "automatic" => { "x" => "y" },
745
+ "chef_environment" => "desert"
746
746
  )
747
747
  end
748
748
 
749
- it 'chef_node with attribute [ c, e, b ], 2, [ c, e ], { a => 1 } sets a only' do
750
- expect_recipe {
751
- chef_node 'blah' do
752
- attribute [ 'c', 'e', 'b' ], 2
753
- attribute [ 'c', 'e' ], { 'a' => 1 }
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
- }.to be_updated
756
- expect(get('nodes/blah')).to include(
757
- 'normal' => {
758
- 'a' => 'b',
759
- 'c' => { 'd' => 'e', 'e' => { 'a' => 1 } },
760
- 'tags' => [ 'a', 'b' ]
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
- 'automatic' => { 'x' => 'y' },
763
- 'chef_environment' => 'desert'
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 'is in OSC mode' do
773
- context 'and is empty' do
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 'the node gets created' do
776
- expect_recipe {
777
- chef_node 'blah'
778
- }.to have_updated 'chef_node[blah]', :create
779
- expect(get('nodes/blah')['name']).to eq('blah')
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