chef-api 0.8.0 → 0.10.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef-api.rb +19 -20
  3. data/lib/chef-api/aclable.rb +35 -0
  4. data/lib/chef-api/authentication.rb +23 -25
  5. data/lib/chef-api/configurable.rb +14 -14
  6. data/lib/chef-api/connection.rb +68 -67
  7. data/lib/chef-api/defaults.rb +25 -24
  8. data/lib/chef-api/error_collection.rb +1 -1
  9. data/lib/chef-api/errors.rb +3 -3
  10. data/lib/chef-api/log.rb +7 -0
  11. data/lib/chef-api/multipart.rb +17 -17
  12. data/lib/chef-api/resource.rb +17 -15
  13. data/lib/chef-api/resources/base.rb +22 -22
  14. data/lib/chef-api/resources/client.rb +5 -3
  15. data/lib/chef-api/resources/collection_proxy.rb +4 -3
  16. data/lib/chef-api/resources/cookbook.rb +2 -2
  17. data/lib/chef-api/resources/cookbook_version.rb +1 -1
  18. data/lib/chef-api/resources/data_bag.rb +4 -4
  19. data/lib/chef-api/resources/data_bag_item.rb +2 -3
  20. data/lib/chef-api/resources/environment.rb +1 -1
  21. data/lib/chef-api/resources/group.rb +15 -0
  22. data/lib/chef-api/resources/node.rb +11 -8
  23. data/lib/chef-api/resources/organization.rb +2 -2
  24. data/lib/chef-api/resources/partial_search.rb +4 -4
  25. data/lib/chef-api/resources/principal.rb +1 -1
  26. data/lib/chef-api/resources/role.rb +2 -1
  27. data/lib/chef-api/resources/search.rb +6 -6
  28. data/lib/chef-api/resources/user.rb +3 -3
  29. data/lib/chef-api/util.rb +8 -8
  30. data/lib/chef-api/validator.rb +3 -3
  31. data/lib/chef-api/validators/base.rb +3 -3
  32. data/lib/chef-api/validators/required.rb +1 -1
  33. data/lib/chef-api/validators/type.rb +1 -1
  34. data/lib/chef-api/version.rb +1 -1
  35. metadata +25 -58
  36. data/.gitignore +0 -21
  37. data/.travis.yml +0 -18
  38. data/CHANGELOG.md +0 -63
  39. data/Gemfile +0 -12
  40. data/README.md +0 -352
  41. data/Rakefile +0 -11
  42. data/chef-api.gemspec +0 -25
  43. data/spec/integration/resources/client_spec.rb +0 -62
  44. data/spec/integration/resources/environment_spec.rb +0 -8
  45. data/spec/integration/resources/node_spec.rb +0 -8
  46. data/spec/integration/resources/partial_search_spec.rb +0 -23
  47. data/spec/integration/resources/role_spec.rb +0 -8
  48. data/spec/integration/resources/search_spec.rb +0 -21
  49. data/spec/integration/resources/user_spec.rb +0 -8
  50. data/spec/spec_helper.rb +0 -32
  51. data/spec/support/chef_server.rb +0 -198
  52. data/spec/support/cookbook.tar.gz +0 -0
  53. data/spec/support/shared/chef_api_resource.rb +0 -91
  54. data/spec/support/user.pem +0 -27
  55. data/spec/unit/authentication_spec.rb +0 -70
  56. data/spec/unit/defaults_spec.rb +0 -60
  57. data/spec/unit/errors_spec.rb +0 -294
  58. data/spec/unit/resources/base_spec.rb +0 -49
  59. data/spec/unit/resources/client_spec.rb +0 -53
  60. data/spec/unit/resources/connection_spec.rb +0 -53
@@ -1,27 +0,0 @@
1
- -----BEGIN RSA PRIVATE KEY-----
2
- MIIEowIBAAKCAQEA1xzQLQxDANx/Yu73NbqATU898uvHcVaMglg4FjMMOhqLTE3g
3
- MIDMUeBH05c167kRmF+6a3l3dNlDyt8cBtWo277Yfd3FPOzeaf/g7umKY0Ids9S4
4
- fZBP+wcG8mpk2ReNiAcIwJlTZHWSdUSoHIZeDXd8eE5tU1WfdWeXfd+yQFVTv5fj
5
- U0VwU/c4+UzMjySbHiv94mKIfels/M7hnlRoJyepJFLThTi5bE4bmyizhvBp6j8V
6
- HbaLdSfBis1FgDuaajSjTu6m41X7HshSuWkRp1w+2PWQnXwoCIBIogHcTlE+UGt6
7
- LNa23/jiMCzRGYQiS/gl5+6gTByhCcV7f2aXXwIDAQABAoIBADYZVvmdVdSHn7nf
8
- 42gtyUqoHSpUxcnpPFkjmqdqmy6ZsmK0SyennLsSrr22D6eC2bv6h0W0PKi0Y2pI
9
- BiJp5ZeuPYAaIBqcb6s04Pr03Qrte87YNrXNb2/wanzY6Rf35m5JZpgZd3GSaAz6
10
- AVV7LXgxjqoq/y+wHvRF40GS2p924BePIzSgwWld2X7s39YdgSrxk2vytuqU2B8m
11
- iH5fhJDghO7MQCX5aa+6YgLAvP28mKTPBOz8kCbiWPgDPxu9NpI4WGgzGgZqofjZ
12
- GIyqZcDQ15oILdi0awWaVAK6Ob/24QQm33QaHzKZTKaRzWUeIJpnqPcGndjRC4Yt
13
- FN/yVKECgYEA7ahqlovJN1AeZ1tDqP9UiGHSKyJmo3psnv3+u5DV+/cUUwDvbLF5
14
- atCaGWZbdd0oSejeNeNX+JKZZE5xxSrKmuFnQe9lljylrWEOZ0TBngi4MABVJvst
15
- vUG21vYVEZGiQzWZqZ92zxJQB3V0hOPNsyyAKVnyKctwhSlO3slbYhcCgYEA57bz
16
- ueFcwQsQuJFLK2fX6ZmMJD0bwMXMOZIb+1s/URAIEClFqJYnYJuT7GGthz8099FL
17
- 2HyrGScrTYL+ekrAFTHmx/hBLdPwYhCunyptUvPPQwU8+mEhKSsqVtjHKnFfyHRB
18
- T2c8AZNQNXhMMeJYANY3Gm1/4catWJ6RF/U1qfkCgYEApDqFrZLbcYXD/NhsYRRQ
19
- bg5rFbOoCcBH33bV2Pe1Z3DOcq1qxkm+BboxQuwgt8okVS6+n66C1Bs6NL6gkAeK
20
- Co1ItZ+hK7itJKq1MVeqFHMiFMmmDlH0wZvvpYxX8tQYtSkNDtJLX7zf4MehxVNG
21
- ilJuHiUx2v/iuaJaBkpPA/ECgYAxNXthOGkYXh848zJBj5Yc+Az5DTk9oUQT3eGv
22
- adtyfbMYq4stmGXYcHHju4K8vEGld39iBGfZuaXKmk0s738HgUd/pEtDTkU4rk5H
23
- Yx1AhqK3mv8uNT5zncUqGHODofwzd+z+ze/CbeSU1m1oEqeZ1eRx6ltEOYtKzLIH
24
- on25EQKBgEpxoKGGbp6EpY/wGCONeapjB/27gRAdLB5Nh/9HCAfVfoM/K31ECmL9
25
- ZWWiwM6U2Qlmh8jGrhN4su8hpsNGbjvZ+kpA0MqJnJQGr6Y7iiSKDtd+Xc1cLh1g
26
- YtL+yxlvdE9ue8oZut4Mfn0xQg2sns+OYi7mWQpssKeR/faPcGkK
27
- -----END RSA PRIVATE KEY-----
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ChefAPI
4
- describe Authentication do
5
- let(:user) { 'sethvargo' }
6
- let(:key) { rspec_support_file('user.pem') }
7
- let(:body) { nil }
8
- let(:verb) { :get }
9
- let(:path) { '/foo/bar' }
10
- let(:timestamp) { '1991-07-23T03:00:54Z' }
11
-
12
- let(:headers) { described_class.new(user, key, verb, path, body).headers }
13
-
14
- before do
15
- allow(Time).to receive_message_chain(:now, :utc, :iso8601)
16
- .and_return(timestamp)
17
- end
18
-
19
- context 'when given a request with no body' do
20
- let(:body) { nil }
21
-
22
- it 'returns the signed headers' do
23
- expect(headers['X-Ops-Sign']).to eq('algorithm=sha1;version=1.0;')
24
- expect(headers['X-Ops-Userid']).to eq('sethvargo')
25
- expect(headers['X-Ops-Timestamp']).to eq('1991-07-23T03:00:54Z')
26
- expect(headers['X-Ops-Content-Hash']).to eq('2jmj7l5rSw0yVb/vlWAYkK/YBwk=')
27
- expect(headers['X-Ops-Authorization-1']).to eq('UuadIvkZTeZDcFW6oNilet0QzTcP/9JsRhSjIKCiZiqUeBG9jz4mU9w+TWsm')
28
- expect(headers['X-Ops-Authorization-2']).to eq('2R3IiEKOW0S+UZpN19tPZ3nTdUluEvguidnsjuM/UpHymgY7M560pN4idXt5')
29
- expect(headers['X-Ops-Authorization-3']).to eq('MQYAEHhFHTOfBX8ihOPkA5gkbLw6ehftjL10W/7H3bTrl1tiHHkv2Lmz4e+e')
30
- expect(headers['X-Ops-Authorization-4']).to eq('9dJNeNDYVEaR1Efj7B7rnKjSD6SvRdqq0gbwiTfE7P2B88yjnq+a9eEoYgG3')
31
- expect(headers['X-Ops-Authorization-5']).to eq('lmNnVT5pqJPHiE1YFj1OITywAi/5pMzJCzYzVyWxQT+4r+SIRtRESrRFi1Re')
32
- expect(headers['X-Ops-Authorization-6']).to eq('OfHqhynKfmxMHAxVLJbfdjH3yX8Z8bq3tGPbdXxYAw==')
33
- end
34
- end
35
-
36
- context 'when given a request with a string body' do
37
- let(:body) { '{ "some": { "json": true } }' }
38
-
39
- it 'returns the signed headers' do
40
- expect(headers['X-Ops-Sign']).to eq('algorithm=sha1;version=1.0;')
41
- expect(headers['X-Ops-Userid']).to eq('sethvargo')
42
- expect(headers['X-Ops-Timestamp']).to eq('1991-07-23T03:00:54Z')
43
- expect(headers['X-Ops-Content-Hash']).to eq('D3+ox1HKmuzp3SLWiSU/5RdnbdY=')
44
- expect(headers['X-Ops-Authorization-1']).to eq('fbV8dt51y832DJS0bfR1LJ+EF/HHiDEgqJawNZyKMkgMHZ0Bv78kQVtH73fS')
45
- expect(headers['X-Ops-Authorization-2']).to eq('s3JQkMpZOwsNO8n2iduexmTthJe/JXG4sUgBKkS2qtKxpBy5snFSb6wD5ZuC')
46
- expect(headers['X-Ops-Authorization-3']).to eq('VJuC1YpOF6bGM8CyUG0O0SZBZRFZVgyC5TFACJn8ymMIx0FznWSPLyvoSjsZ')
47
- expect(headers['X-Ops-Authorization-4']).to eq('pdVOjhPV2+EQaj3c01dBFx5FSXgnBhWSmu2DCel/74TDt5RBraPcB4wczwpz')
48
- expect(headers['X-Ops-Authorization-5']).to eq('VIeVqGMuQ71OE0tabej4OKyf1+BopOedxVH1+KF5ETisxqrNhmEtUY5WrmSS')
49
- expect(headers['X-Ops-Authorization-6']).to eq('hjhiBXFdieV24Sojq6PKBhEEwpJqrPVP1lZNkRXdoA==')
50
- end
51
- end
52
-
53
- context 'when given an IO object' do
54
- let(:body) { File.open(rspec_support_file('cookbook.tar.gz')) }
55
-
56
- it 'returns the signed headers' do
57
- expect(headers['X-Ops-Sign']).to eq('algorithm=sha1;version=1.0;')
58
- expect(headers['X-Ops-Userid']).to eq('sethvargo')
59
- expect(headers['X-Ops-Timestamp']).to eq('1991-07-23T03:00:54Z')
60
- expect(headers['X-Ops-Content-Hash']).to eq('AWFSGfxiL2XltqdgSKCpdm84H9o=')
61
- expect(headers['X-Ops-Authorization-1']).to eq('oRvANxtLQanzqdC28l0szONjTni9zLRBiybYNyxyxos7M1X3kSs5LknmMA/E')
62
- expect(headers['X-Ops-Authorization-2']).to eq('i6Izk87dCcG3LLiGqRh0x/BoayS9SyoctdfMRR5ivrKRUzuQU9elHRpXnmjw')
63
- expect(headers['X-Ops-Authorization-3']).to eq('7i/tlbLPrJQ/0+di9BU4m+BBD/vbh80KajmsaszxHx1wwNEBkNAymSLSDqXX')
64
- expect(headers['X-Ops-Authorization-4']).to eq('gVAjNiaEzV9/EPQyGAYaU40SOdDwKzBthxgCpM9sfpfQsXj4Oj4SvSmO+4sy')
65
- expect(headers['X-Ops-Authorization-5']).to eq('eJ0l7vpR0MyQqnhqbJHkQAGsG/HUhuhG0E9T7dClk08EB+sdsnDxr+5laei3')
66
- expect(headers['X-Ops-Authorization-6']).to eq('YtCw2spOnumfdqx2hWvLmxR3y2eOuLBv77tZXUQ4Ug==')
67
- end
68
- end
69
- end
70
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ChefAPI
4
- describe Defaults do
5
- before(:each) do
6
- subject.instance_variable_set(:@config, nil)
7
- end
8
-
9
- context 'without a config file' do
10
- before(:each) do
11
- allow(subject).to receive(:config).and_return(Hash.new)
12
- end
13
-
14
- it 'returns the default endpoint' do
15
- expect(subject.endpoint).to eq subject::ENDPOINT
16
- end
17
-
18
- it 'returns the default user agent' do
19
- expect(subject.user_agent).to eq subject::USER_AGENT
20
- end
21
- end
22
-
23
- context 'without a config file and no ENV vars to find it' do
24
- around do |example|
25
- old_conf = ENV.delete('CHEF_API_CONFIG')
26
- old_home = ENV.delete('HOME')
27
- example.run
28
- ENV['CHEF_API_CONFIG'] = old_conf
29
- ENV['HOME'] = old_home
30
- end
31
-
32
- it 'returns the default without errors' do
33
- expect { subject.config }.not_to raise_error
34
- end
35
-
36
- it 'returns the default which is the empty hash' do
37
- expect(subject.config).to eq({})
38
- end
39
- end
40
-
41
- context 'with a config file' do
42
- before(:each) do
43
- config_content = "{\n"\
44
- "\"CHEF_API_ENDPOINT\": \"test_endpoint\",\n" \
45
- "\"CHEF_API_USER_AGENT\": \"test_user_agent\"\n" \
46
- "}"
47
- path = instance_double(Pathname, read: config_content, exist?: true)
48
- allow(subject).to receive(:config_path).and_return(path)
49
- end
50
-
51
- it 'returns the overridden value for endpoint' do
52
- expect(subject.endpoint).to eq 'test_endpoint'
53
- end
54
-
55
- it 'returns the overridden value for user agent' do
56
- expect(subject.user_agent).to eq 'test_user_agent'
57
- end
58
- end
59
- end
60
- end
@@ -1,294 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ChefAPI::Error
4
- describe ChefAPIError do
5
- let(:instance) { described_class.new }
6
-
7
- it 'raises an exception with the correct message' do
8
- expect { raise instance }.to raise_error { |error|
9
- expect(error).to be_a(described_class)
10
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
11
- Oh no! Something really bad happened. I am not sure what actually happened because this is the catch-all error, but you should most definitely report an issue on GitHub at https://github.com/sethvargo/chef-api.
12
- EOH
13
- }
14
- end
15
- end
16
-
17
- describe AbstractMethod do
18
- let(:instance) { described_class.new(method: 'Resource#load') }
19
-
20
- it 'raises an exception with the correct message' do
21
- expect { raise instance }.to raise_error { |error|
22
- expect(error).to be_a(described_class)
23
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
24
- 'Resource#load' is an abstract method. You must override this method in your subclass with the proper implementation and logic. For more information, please see the inline documentation for Resource#load. If you are not a developer, this is most likely a bug in the ChefAPI gem. Please file a bug report at:
25
-
26
- https://github.com/sethvargo/chef-api/issues/new
27
-
28
- and include the command(s) or code you ran to arrive at this error.
29
- EOH
30
- }
31
- end
32
- end
33
-
34
- describe CannotRegenerateKey do
35
- let(:instance) { described_class.new }
36
-
37
- it 'raises an exception with the correct message' do
38
- expect { raise instance }.to raise_error { |error|
39
- expect(error).to be_a(described_class)
40
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
41
- You attempted to regenerate the private key for a Client or User that does not yet exist on the remote Chef Server. You can only regenerate the key for an object that is persisted. Try saving this record this object before regenerating the key.
42
- EOH
43
- }
44
- end
45
- end
46
-
47
- describe FileNotFound do
48
- let(:instance) { described_class.new(path: '/path/to/file.rb') }
49
-
50
- it 'raises an exception with the correct message' do
51
- expect { raise instance }.to raise_error { |error|
52
- expect(error).to be_a(described_class)
53
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
54
- I could not find a file at '/path/to/file.rb'. Please make sure you have typed the path correctly and that the resource exists at the given path.
55
- EOH
56
- }
57
- end
58
- end
59
-
60
- describe HTTPBadRequest do
61
- let(:instance) { described_class.new(message: 'Something happened...') }
62
-
63
- it 'raises an exception with the correct message' do
64
- expect { raise instance }.to raise_error { |error|
65
- expect(error).to be_a(described_class)
66
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
67
- The Chef Server did not understand the request because it was malformed.
68
-
69
- Something happened...
70
- EOH
71
- }
72
- end
73
- end
74
-
75
- describe HTTPForbiddenRequest do
76
- let(:instance) { described_class.new(message: 'Something happened...') }
77
-
78
- it 'raises an exception with the correct message' do
79
- expect { raise instance }.to raise_error { |error|
80
- expect(error).to be_a(described_class)
81
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
82
- The Chef Server actively refused to fulfill the request.
83
-
84
- Something happened...
85
- EOH
86
- }
87
- end
88
- end
89
-
90
- describe HTTPGatewayTimeout do
91
- let(:instance) { described_class.new(message: 'Something happened...') }
92
-
93
- it 'raises an exception with the correct message' do
94
- expect { raise instance }.to raise_error { |error|
95
- expect(error).to be_a(described_class)
96
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
97
- The Chef Server did not respond in an adequate amount of time.
98
-
99
- Something happened...
100
- EOH
101
- }
102
- end
103
- end
104
-
105
- describe HTTPMethodNotAllowed do
106
- let(:instance) { described_class.new(message: 'Something happened...') }
107
-
108
- it 'raises an exception with the correct message' do
109
- expect { raise instance }.to raise_error { |error|
110
- expect(error).to be_a(described_class)
111
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
112
- That HTTP method is not allowed on this URL.
113
-
114
- Something happened...
115
- EOH
116
- }
117
- end
118
- end
119
-
120
- describe HTTPNotAcceptable do
121
- let(:instance) { described_class.new(message: 'Something happened...') }
122
-
123
- it 'raises an exception with the correct message' do
124
- expect { raise instance }.to raise_error { |error|
125
- expect(error).to be_a(described_class)
126
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
127
- The Chef Server identified this request as unacceptable. This usually means you have not specified the correct Accept or Content-Type headers on the request.
128
-
129
- Something happened...
130
- EOH
131
- }
132
- end
133
- end
134
-
135
- describe HTTPNotFound do
136
- let(:instance) { described_class.new(message: 'Something happened...') }
137
-
138
- it 'raises an exception with the correct message' do
139
- expect { raise instance }.to raise_error { |error|
140
- expect(error).to be_a(described_class)
141
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
142
- The requested URL does not exist on the Chef Server.
143
-
144
- Something happened...
145
- EOH
146
- }
147
- end
148
- end
149
-
150
- describe HTTPServerUnavailable do
151
- let(:instance) { described_class.new }
152
-
153
- it 'raises an exception with the correct message' do
154
- expect { raise instance }.to raise_error { |error|
155
- expect(error).to be_a(described_class)
156
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
157
- The Chef Server is currently unavailable or is not currently accepting client connections. Please ensure the server is accessible via ping or telnet on your local network. If this error persists, please contact your network administrator.
158
- EOH
159
- }
160
- end
161
- end
162
-
163
- describe HTTPUnauthorizedRequest do
164
- let(:instance) { described_class.new(message: 'Something happened...') }
165
-
166
- it 'raises an exception with the correct message' do
167
- expect { raise instance }.to raise_error { |error|
168
- expect(error).to be_a(described_class)
169
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
170
- The Chef Server requires authorization. Please ensure you have specified the correct client name and private key. If this error continues, please verify the given client has the proper permissions on the Chef Server.
171
-
172
- Something happened...
173
- EOH
174
- }
175
- end
176
- end
177
-
178
- describe InsufficientFilePermissions do
179
- let(:instance) { described_class.new(path: '/path/to/file.rb') }
180
-
181
- it 'raises an exception with the correct message' do
182
- expect { raise instance }.to raise_error { |error|
183
- expect(error).to be_a(described_class)
184
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
185
- I cannot read the file at '/path/to/file.rb' because the permissions on the file do not permit it. Please ensure the file has the correct permissions and that this Ruby process is running as a user with access to that path.
186
- EOH
187
- }
188
- end
189
- end
190
-
191
- describe InvalidResource do
192
- let(:instance) { described_class.new(errors: 'Missing a thing!') }
193
-
194
- it 'raises an exception with the correct message' do
195
- expect { raise instance }.to raise_error { |error|
196
- expect(error).to be_a(described_class)
197
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
198
- There were errors saving your resource: Missing a thing!
199
- EOH
200
- }
201
- end
202
- end
203
-
204
- describe InvalidValidator do
205
- let(:instance) { described_class.new(key: 'bacon') }
206
-
207
- it 'raises an exception with the correct message' do
208
- expect { raise instance }.to raise_error { |error|
209
- expect(error).to be_a(described_class)
210
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
211
- 'bacon' is not a valid validator. Please make sure it is spelled correctly and that the constant is properly defined. If you are using a custom validator, please ensure the validator extends ChefAPI::Validator::Base and is a subclass of ChefAPI::Validator.
212
- EOH
213
- }
214
- end
215
- end
216
-
217
- describe MissingURLParameter do
218
- let(:instance) { described_class.new(param: 'user') }
219
-
220
- it 'raises an exception with the correct message' do
221
- expect { raise instance }.to raise_error { |error|
222
- expect(error).to be_a(described_class)
223
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
224
- The required URL parameter 'user' was not present. Please specify the parameter as an option, like Resource.new(id, user: 'value').
225
- EOH
226
- }
227
- end
228
- end
229
-
230
- describe NotADirectory do
231
- let(:instance) { described_class.new(path: '/path/to/directory') }
232
-
233
- it 'raises an exception with the correct message' do
234
- expect { raise instance }.to raise_error { |error|
235
- expect(error).to be_a(described_class)
236
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
237
- The given path '/path/to/directory' is not a directory. Please make sure you have passed the path to a directory on disk.
238
- EOH
239
- }
240
- end
241
- end
242
-
243
- describe ResourceAlreadyExists do
244
- let(:instance) { described_class.new(type: 'client', id: 'bacon') }
245
-
246
- it 'raises an exception with the correct message' do
247
- expect { raise instance }.to raise_error { |error|
248
- expect(error).to be_a(described_class)
249
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
250
- The client 'bacon' already exists on the Chef Server. Each client must have a unique identifier and the Chef Server indicated this client already exists. If you are trying to update the client, consider using the 'update' method instead.
251
- EOH
252
- }
253
- end
254
- end
255
-
256
- describe ResourceNotFound do
257
- let(:instance) { described_class.new(type: 'client', id: 'bacon') }
258
-
259
- it 'raises an exception with the correct message' do
260
- expect { raise instance }.to raise_error { |error|
261
- expect(error).to be_a(described_class)
262
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
263
- There is no client with an id of 'bacon' on the Chef Server. If you are updating the client, please make sure the client exists and has the correct Chef identifier (primary key).
264
- EOH
265
- }
266
- end
267
- end
268
-
269
- describe ResourceNotMutable do
270
- let(:instance) { described_class.new(type: 'client', id: 'bacon') }
271
-
272
- it 'raises an exception with the correct message' do
273
- expect { raise instance }.to raise_error { |error|
274
- expect(error).to be_a(described_class)
275
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
276
- The client 'bacon' is not mutable. It may be locked by the remote Chef Server, or the Chef Server may not permit modifying the resource.
277
- EOH
278
- }
279
- end
280
- end
281
-
282
- describe UnknownAttribute do
283
- let(:instance) { described_class.new(attribute: 'name') }
284
-
285
- it 'raises an exception with the correct message' do
286
- expect { raise instance }.to raise_error { |error|
287
- expect(error).to be_a(described_class)
288
- expect(error.message).to eq <<-EOH.gsub(/^ {10}/, '')
289
- 'name' is not a valid attribute!
290
- EOH
291
- }
292
- end
293
- end
294
- end