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.
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,221 +1,221 @@
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::ChefOrganization do
5
5
  extend Cheffish::RSpec::ChefRunSupport
6
6
 
7
- when_the_chef_12_server 'is in multi-org mode' do
8
- context 'and chef_server_url is pointed at the top level' do
9
- user 'u', {}
10
- user 'u2', {}
7
+ when_the_chef_12_server "is in multi-org mode" do
8
+ context "and chef_server_url is pointed at the top level" do
9
+ user "u", {}
10
+ user "u2", {}
11
11
 
12
12
  it 'chef_organization "x" creates the organization' do
13
- expect_recipe {
14
- chef_organization 'x'
15
- }.to have_updated('chef_organization[x]', :create)
16
- expect(get('/organizations/x')['full_name']).to eq('x')
13
+ expect_recipe do
14
+ chef_organization "x"
15
+ end.to have_updated("chef_organization[x]", :create)
16
+ expect(get("/organizations/x")["full_name"]).to eq("x")
17
17
  end
18
18
  end
19
19
 
20
- context 'and chef_server_url is pointed at /organizations/foo' do
21
- organization 'foo'
20
+ context "and chef_server_url is pointed at /organizations/foo" do
21
+ organization "foo"
22
22
 
23
23
  before :each do
24
- Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
24
+ Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
25
25
  end
26
26
 
27
- context 'and is empty' do
28
- user 'u', {}
29
- user 'u2', {}
27
+ context "and is empty" do
28
+ user "u", {}
29
+ user "u2", {}
30
30
 
31
31
  it 'chef_organization "x" creates the organization' do
32
- expect_recipe {
33
- chef_organization 'x'
34
- }.to have_updated('chef_organization[x]', :create)
35
- expect(get('/organizations/x')['full_name']).to eq('x')
32
+ expect_recipe do
33
+ chef_organization "x"
34
+ end.to have_updated("chef_organization[x]", :create)
35
+ expect(get("/organizations/x")["full_name"]).to eq("x")
36
36
  end
37
37
 
38
38
  it 'chef_organization "x" with full_name creates the organization' do
39
- expect_recipe {
40
- chef_organization 'x' do
41
- full_name 'Hi'
39
+ expect_recipe do
40
+ chef_organization "x" do
41
+ full_name "Hi"
42
42
  end
43
- }.to have_updated('chef_organization[x]', :create)
44
- expect(get('/organizations/x')['full_name']).to eq('Hi')
43
+ end.to have_updated("chef_organization[x]", :create)
44
+ expect(get("/organizations/x")["full_name"]).to eq("Hi")
45
45
  end
46
46
 
47
47
  it 'chef_organization "x" and inviting users creates the invites' do
48
- expect_recipe {
49
- chef_organization 'x' do
50
- invites 'u', 'u2'
48
+ expect_recipe do
49
+ chef_organization "x" do
50
+ invites "u", "u2"
51
51
  end
52
- }.to have_updated('chef_organization[x]', :create)
53
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(u u2))
52
+ end.to have_updated("chef_organization[x]", :create)
53
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{u u2})
54
54
  end
55
55
 
56
56
  it 'chef_organization "x" adds members' do
57
- expect_recipe {
58
- chef_organization 'x' do
59
- members 'u', 'u2'
57
+ expect_recipe do
58
+ chef_organization "x" do
59
+ members "u", "u2"
60
60
  end
61
- }.to have_updated('chef_organization[x]', :create)
62
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(u u2))
61
+ end.to have_updated("chef_organization[x]", :create)
62
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{u u2})
63
63
  end
64
64
  end
65
65
 
66
- context 'and already has an organization named x' do
67
- user 'u', {}
68
- user 'u2', {}
69
- user 'u3', {}
70
- user 'member', {}
71
- user 'member2', {}
72
- user 'invited', {}
73
- user 'invited2', {}
74
- organization 'x', { 'full_name' => 'Lo' } do
75
- org_member 'member', 'member2'
76
- org_invite 'invited', 'invited2'
66
+ context "and already has an organization named x" do
67
+ user "u", {}
68
+ user "u2", {}
69
+ user "u3", {}
70
+ user "member", {}
71
+ user "member2", {}
72
+ user "invited", {}
73
+ user "invited2", {}
74
+ organization "x", { "full_name" => "Lo" } do
75
+ org_member "member", "member2"
76
+ org_invite "invited", "invited2"
77
77
  end
78
78
 
79
79
  it 'chef_organization "x" changes nothing' do
80
- expect_recipe {
81
- chef_organization 'x'
82
- }.not_to have_updated('chef_organization[x]', :create)
83
- expect(get('/organizations/x')['full_name']).to eq('Lo')
80
+ expect_recipe do
81
+ chef_organization "x"
82
+ end.not_to have_updated("chef_organization[x]", :create)
83
+ expect(get("/organizations/x")["full_name"]).to eq("Lo")
84
84
  end
85
85
 
86
86
  it 'chef_organization "x" with "complete true" reverts the full_name' do
87
- expect_recipe {
88
- chef_organization 'x' do
87
+ expect_recipe do
88
+ chef_organization "x" do
89
89
  complete true
90
90
  end
91
- }.to have_updated('chef_organization[x]', :create)
92
- expect(get('/organizations/x')['full_name']).to eq('x')
91
+ end.to have_updated("chef_organization[x]", :create)
92
+ expect(get("/organizations/x")["full_name"]).to eq("x")
93
93
  end
94
94
 
95
95
  it 'chef_organization "x" with new full_name updates the organization' do
96
- expect_recipe {
97
- chef_organization 'x' do
98
- full_name 'Hi'
96
+ expect_recipe do
97
+ chef_organization "x" do
98
+ full_name "Hi"
99
99
  end
100
- }.to have_updated('chef_organization[x]', :create)
101
- expect(get('/organizations/x')['full_name']).to eq('Hi')
100
+ end.to have_updated("chef_organization[x]", :create)
101
+ expect(get("/organizations/x")["full_name"]).to eq("Hi")
102
102
  end
103
103
 
104
- context 'invites and membership tests' do
104
+ context "invites and membership tests" do
105
105
  it 'chef_organization "x" and inviting users creates the invites' do
106
- expect_recipe {
107
- chef_organization 'x' do
108
- invites 'u', 'u2'
106
+ expect_recipe do
107
+ chef_organization "x" do
108
+ invites "u", "u2"
109
109
  end
110
- }.to have_updated('chef_organization[x]', :create)
111
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2 u u2))
110
+ end.to have_updated("chef_organization[x]", :create)
111
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{invited invited2 u u2})
112
112
  end
113
113
 
114
114
  it 'chef_organization "x" adds members' do
115
- expect_recipe {
116
- chef_organization 'x' do
117
- members 'u', 'u2'
115
+ expect_recipe do
116
+ chef_organization "x" do
117
+ members "u", "u2"
118
118
  end
119
- }.to have_updated('chef_organization[x]', :create)
120
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2 u u2))
119
+ end.to have_updated("chef_organization[x]", :create)
120
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{member member2 u u2})
121
121
  end
122
122
 
123
123
  it 'chef_organization "x" does nothing when inviting already-invited users and members' do
124
- expect_recipe {
125
- chef_organization 'x' do
126
- invites 'invited', 'member'
124
+ expect_recipe do
125
+ chef_organization "x" do
126
+ invites "invited", "member"
127
127
  end
128
- }.not_to have_updated('chef_organization[x]', :create)
129
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
130
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
128
+ end.not_to have_updated("chef_organization[x]", :create)
129
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{invited invited2})
130
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{member member2})
131
131
  end
132
132
 
133
133
  it 'chef_organization "x" does nothing when adding members who are already members' do
134
- expect_recipe {
135
- chef_organization 'x' do
136
- members 'member'
134
+ expect_recipe do
135
+ chef_organization "x" do
136
+ members "member"
137
137
  end
138
- }.not_to have_updated('chef_organization[x]', :create)
139
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
140
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
138
+ end.not_to have_updated("chef_organization[x]", :create)
139
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{invited invited2})
140
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{member member2})
141
141
  end
142
142
 
143
143
  it 'chef_organization "x" upgrades invites to members when asked' do
144
- expect_recipe {
145
- chef_organization 'x' do
146
- members 'invited'
144
+ expect_recipe do
145
+ chef_organization "x" do
146
+ members "invited"
147
147
  end
148
- }.to have_updated('chef_organization[x]', :create)
149
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(invited member member2))
150
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited2))
148
+ end.to have_updated("chef_organization[x]", :create)
149
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{invited member member2})
150
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{invited2})
151
151
  end
152
152
 
153
153
  it 'chef_organization "x" removes members and invites when asked' do
154
- expect_recipe {
155
- chef_organization 'x' do
156
- remove_members 'invited', 'member'
154
+ expect_recipe do
155
+ chef_organization "x" do
156
+ remove_members "invited", "member"
157
157
  end
158
- }.to have_updated('chef_organization[x]', :create)
159
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited2))
160
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member2))
158
+ end.to have_updated("chef_organization[x]", :create)
159
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{invited2})
160
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{member2})
161
161
  end
162
162
 
163
163
  it 'chef_organization "x" does nothing when asked to remove non-members' do
164
- expect_recipe {
165
- chef_organization 'x' do
166
- remove_members 'u', 'u2'
164
+ expect_recipe do
165
+ chef_organization "x" do
166
+ remove_members "u", "u2"
167
167
  end
168
- }.not_to have_updated('chef_organization[x]', :create)
169
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
170
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
168
+ end.not_to have_updated("chef_organization[x]", :create)
169
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{invited invited2})
170
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{member member2})
171
171
  end
172
172
 
173
173
  it 'chef_organization "x" with "complete true" reverts the full_name but does not remove invites or members' do
174
- expect_recipe {
175
- chef_organization 'x' do
174
+ expect_recipe do
175
+ chef_organization "x" do
176
176
  complete true
177
177
  end
178
- }.to have_updated('chef_organization[x]', :create)
179
- expect(get('/organizations/x')['full_name']).to eq('x')
180
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited invited2))
181
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
178
+ end.to have_updated("chef_organization[x]", :create)
179
+ expect(get("/organizations/x")["full_name"]).to eq("x")
180
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{invited invited2})
181
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{member member2})
182
182
  end
183
183
 
184
184
  it 'chef_organization "x" with members [] and "complete true" removes invites and members' do
185
- expect_recipe {
186
- chef_organization 'x' do
185
+ expect_recipe do
186
+ chef_organization "x" do
187
187
  members []
188
188
  complete true
189
189
  end
190
- }.to have_updated('chef_organization[x]', :create)
191
- expect(get('/organizations/x')['full_name']).to eq('x')
192
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq([])
193
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq([])
190
+ end.to have_updated("chef_organization[x]", :create)
191
+ expect(get("/organizations/x")["full_name"]).to eq("x")
192
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq([])
193
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq([])
194
194
  end
195
195
 
196
196
  it 'chef_organization "x" with invites [] and "complete true" removes invites but not members' do
197
- expect_recipe {
198
- chef_organization 'x' do
197
+ expect_recipe do
198
+ chef_organization "x" do
199
199
  invites []
200
200
  complete true
201
201
  end
202
- }.to have_updated('chef_organization[x]', :create)
203
- expect(get('/organizations/x')['full_name']).to eq('x')
204
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq([])
205
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member member2))
202
+ end.to have_updated("chef_organization[x]", :create)
203
+ expect(get("/organizations/x")["full_name"]).to eq("x")
204
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq([])
205
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{member member2})
206
206
  end
207
207
 
208
208
  it 'chef_organization "x" with invites, members and "complete true" removes all non-specified invites and members' do
209
- expect_recipe {
210
- chef_organization 'x' do
211
- invites 'invited', 'u'
212
- members 'member', 'u2'
209
+ expect_recipe do
210
+ chef_organization "x" do
211
+ invites "invited", "u"
212
+ members "member", "u2"
213
213
  complete true
214
214
  end
215
- }.to have_updated('chef_organization[x]', :create)
216
- expect(get('/organizations/x')['full_name']).to eq('x')
217
- expect(get('/organizations/x/association_requests').map { |u| u['username'] }).to eq(%w(invited u))
218
- expect(get('/organizations/x/users').map { |u| u['user']['username'] }).to eq(%w(member u2))
215
+ end.to have_updated("chef_organization[x]", :create)
216
+ expect(get("/organizations/x")["full_name"]).to eq("x")
217
+ expect(get("/organizations/x/association_requests").map { |u| u["username"] }).to eq(%w{invited u})
218
+ expect(get("/organizations/x/users").map { |u| u["user"]["username"] }).to eq(%w{member u2})
219
219
  end
220
220
  end
221
221
  end
@@ -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::ChefRole 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 role "blah"' do
16
- it 'the role gets created' do
17
- expect_recipe {
18
- chef_role 'blah'
19
- }.to have_updated 'chef_role[blah]', :create
20
- expect(get('roles/blah')['name']).to eq('blah')
16
+ it "the role gets created" do
17
+ expect_recipe do
18
+ chef_role "blah"
19
+ end.to have_updated "chef_role[blah]", :create
20
+ expect(get("roles/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,40 +35,40 @@ describe Chef::Resource::ChefRole do
35
35
 
36
36
  context 'and a recipe is run that creates role "blah" on the second chef server using with_chef_server' do
37
37
 
38
- it 'the role 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_role 'blah'
42
- }.to have_updated 'chef_role[blah]', :create
43
- expect { get('roles/blah') }.to raise_error(Net::HTTPServerException)
44
- expect(get('http://127.0.0.1:8899/roles/blah')['name']).to eq('blah')
38
+ it "the role 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_role "blah"
42
+ end.to have_updated "chef_role[blah]", :create
43
+ expect { get("roles/blah") }.to raise_error(Net::HTTPServerException)
44
+ expect(get("http://127.0.0.1:8899/roles/blah")["name"]).to eq("blah")
45
45
  end
46
46
  end
47
47
 
48
48
  context 'and a recipe is run that creates role "blah" on the second chef server using chef_server' do
49
49
 
50
- it 'the role is created on the second chef server but not the first' do
51
- expect_recipe {
52
- chef_role 'blah' do
53
- chef_server({ :chef_server_url => 'http://127.0.0.1:8899' })
50
+ it "the role is created on the second chef server but not the first" do
51
+ expect_recipe do
52
+ chef_role "blah" do
53
+ chef_server({ :chef_server_url => "http://127.0.0.1:8899" })
54
54
  end
55
- }.to have_updated 'chef_role[blah]', :create
56
- expect { get('roles/blah') }.to raise_error(Net::HTTPServerException)
57
- expect(get('http://127.0.0.1:8899/roles/blah')['name']).to eq('blah')
55
+ end.to have_updated "chef_role[blah]", :create
56
+ expect { get("roles/blah") }.to raise_error(Net::HTTPServerException)
57
+ expect(get("http://127.0.0.1:8899/roles/blah")["name"]).to eq("blah")
58
58
  end
59
59
  end
60
60
  end
61
61
  end
62
62
  end
63
63
 
64
- when_the_chef_server 'is in OSC mode' do
65
- context 'and is empty' do
64
+ when_the_chef_server "is in OSC mode" do
65
+ context "and is empty" do
66
66
  context 'and we run a recipe that creates role "blah"' do
67
- it 'the role gets created' do
68
- expect_recipe {
69
- chef_role 'blah'
70
- }.to have_updated 'chef_role[blah]', :create
71
- expect(get('roles/blah')['name']).to eq('blah')
67
+ it "the role gets created" do
68
+ expect_recipe do
69
+ chef_role "blah"
70
+ end.to have_updated "chef_role[blah]", :create
71
+ expect(get("roles/blah")["name"]).to eq("blah")
72
72
  end
73
73
  end
74
74
  end
@@ -1,8 +1,8 @@
1
- require 'support/spec_support'
2
- require 'cheffish/rspec/chef_run_support'
3
- require 'support/key_support'
1
+ require "support/spec_support"
2
+ require "cheffish/rspec/chef_run_support"
3
+ require "support/key_support"
4
4
 
5
- repo_path = Dir.mktmpdir('chef_repo')
5
+ repo_path = Dir.mktmpdir("chef_repo")
6
6
 
7
7
  describe Chef::Resource::ChefUser do
8
8
  extend Cheffish::RSpec::ChefRunSupport
@@ -11,70 +11,70 @@ describe Chef::Resource::ChefUser do
11
11
  private_key "#{repo_path}/blah.pem"
12
12
  end
13
13
 
14
- when_the_chef_server 'is empty' do
15
- context 'and we run a recipe that creates user "blah"'do
16
- it 'the user gets created' do
17
- expect_recipe {
18
- chef_user 'blah' do
14
+ when_the_chef_server "is empty" do
15
+ context 'and we run a recipe that creates user "blah"' do
16
+ it "the user gets created" do
17
+ expect_recipe do
18
+ chef_user "blah" do
19
19
  source_key_path "#{repo_path}/blah.pem"
20
20
  end
21
- }.to have_updated 'chef_user[blah]', :create
22
- user = get('/users/blah')
23
- expect(user['name']).to eq('blah')
24
- key, format = Cheffish::KeyFormatter.decode(user['public_key'])
21
+ end.to have_updated "chef_user[blah]", :create
22
+ user = get("/users/blah")
23
+ expect(user["name"]).to eq("blah")
24
+ key, format = Cheffish::KeyFormatter.decode(user["public_key"])
25
25
  expect(key).to be_public_key_for("#{repo_path}/blah.pem")
26
26
  end
27
27
  end
28
28
 
29
29
  context 'and we run a recipe that creates user "blah" with output_key_path' do
30
30
  with_converge do
31
- chef_user 'blah' do
31
+ chef_user "blah" do
32
32
  source_key_path "#{repo_path}/blah.pem"
33
33
  output_key_path "#{repo_path}/blah.pub"
34
34
  end
35
35
  end
36
36
 
37
- it 'the output public key gets created' do
38
- expect(IO.read("#{repo_path}/blah.pub")).to start_with('ssh-rsa ')
37
+ it "the output public key gets created" do
38
+ expect(IO.read("#{repo_path}/blah.pub")).to start_with("ssh-rsa ")
39
39
  expect("#{repo_path}/blah.pub").to be_public_key_for("#{repo_path}/blah.pem")
40
40
  end
41
41
  end
42
42
  end
43
43
 
44
- when_the_chef_12_server 'is in multi-org mode' do
45
- context 'and chef_server_url is pointed at the top level' do
46
- context 'and we run a recipe that creates user "blah"'do
47
- it 'the user gets created' do
48
- expect_recipe {
49
- chef_user 'blah' do
44
+ when_the_chef_12_server "is in multi-org mode" do
45
+ context "and chef_server_url is pointed at the top level" do
46
+ context 'and we run a recipe that creates user "blah"' do
47
+ it "the user gets created" do
48
+ expect_recipe do
49
+ chef_user "blah" do
50
50
  source_key_path "#{repo_path}/blah.pem"
51
51
  end
52
- }.to have_updated 'chef_user[blah]', :create
53
- user = get('/users/blah')
54
- expect(user['name']).to eq('blah')
55
- key, format = Cheffish::KeyFormatter.decode(user['public_key'])
52
+ end.to have_updated "chef_user[blah]", :create
53
+ user = get("/users/blah")
54
+ expect(user["name"]).to eq("blah")
55
+ key, format = Cheffish::KeyFormatter.decode(user["public_key"])
56
56
  expect(key).to be_public_key_for("#{repo_path}/blah.pem")
57
57
  end
58
58
  end
59
59
  end
60
60
 
61
- context 'and chef_server_url is pointed at /organizations/foo' do
62
- organization 'foo'
61
+ context "and chef_server_url is pointed at /organizations/foo" do
62
+ organization "foo"
63
63
 
64
64
  before :each do
65
- Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo').to_s
65
+ Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo").to_s
66
66
  end
67
67
 
68
- context 'and we run a recipe that creates user "blah"'do
69
- it 'the user gets created' do
70
- expect_recipe {
71
- chef_user 'blah' do
68
+ context 'and we run a recipe that creates user "blah"' do
69
+ it "the user gets created" do
70
+ expect_recipe do
71
+ chef_user "blah" do
72
72
  source_key_path "#{repo_path}/blah.pem"
73
73
  end
74
- }.to have_updated 'chef_user[blah]', :create
75
- user = get('/users/blah')
76
- expect(user['name']).to eq('blah')
77
- key, format = Cheffish::KeyFormatter.decode(user['public_key'])
74
+ end.to have_updated "chef_user[blah]", :create
75
+ user = get("/users/blah")
76
+ expect(user["name"]).to eq("blah")
77
+ key, format = Cheffish::KeyFormatter.decode(user["public_key"])
78
78
  expect(key).to be_public_key_for("#{repo_path}/blah.pem")
79
79
  end
80
80
  end