ridley 4.0.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/Rakefile +1 -0
- data/lib/ridley/chef/config.rb +5 -5
- data/lib/ridley/chef/cookbook/metadata.rb +59 -14
- data/lib/ridley/chef/cookbook/syntax_check.rb +57 -19
- data/lib/ridley/chef/cookbook.rb +1 -1
- data/lib/ridley/chef/digester.rb +3 -1
- data/lib/ridley/client.rb +6 -3
- data/lib/ridley/connection.rb +5 -4
- data/lib/ridley/errors.rb +1 -0
- data/lib/ridley/helpers.rb +10 -0
- data/lib/ridley/mixin/params_validate.rb +4 -0
- data/lib/ridley/resources/cookbook_resource.rb +14 -2
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +5 -5
- data/spec/acceptance/client_resource_spec.rb +12 -12
- data/spec/acceptance/cookbook_resource_spec.rb +15 -15
- data/spec/acceptance/data_bag_item_resource_spec.rb +14 -14
- data/spec/acceptance/data_bag_resource_spec.rb +4 -4
- data/spec/acceptance/environment_resource_spec.rb +14 -14
- data/spec/acceptance/node_resource_spec.rb +15 -15
- data/spec/acceptance/role_resource_spec.rb +14 -14
- data/spec/acceptance/sandbox_resource_spec.rb +3 -3
- data/spec/acceptance/search_resource_spec.rb +6 -6
- data/spec/acceptance/user_resource_spec.rb +21 -21
- data/spec/support/each_matcher.rb +2 -2
- data/spec/support/filepath_matchers.rb +2 -2
- data/spec/support/shared_examples/ridley_resource.rb +39 -39
- data/spec/unit/ridley/chef/cookbook/metadata_spec.rb +8 -8
- data/spec/unit/ridley/chef/cookbook/syntax_check_spec.rb +15 -15
- data/spec/unit/ridley/chef/cookbook_spec.rb +159 -114
- data/spec/unit/ridley/chef/digester_spec.rb +2 -2
- data/spec/unit/ridley/chef_object_spec.rb +35 -35
- data/spec/unit/ridley/chef_objects/client_object_spec.rb +2 -2
- data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +12 -12
- data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +7 -7
- data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +4 -1
- data/spec/unit/ridley/chef_objects/environment_object_spec.rb +10 -10
- data/spec/unit/ridley/chef_objects/node_object_spec.rb +28 -28
- data/spec/unit/ridley/chef_objects/role_object_spec.rb +10 -10
- data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +6 -6
- data/spec/unit/ridley/client_spec.rb +59 -21
- data/spec/unit/ridley/connection_spec.rb +7 -7
- data/spec/unit/ridley/errors_spec.rb +3 -3
- data/spec/unit/ridley/middleware/chef_auth_spec.rb +2 -2
- data/spec/unit/ridley/middleware/chef_response_spec.rb +29 -29
- data/spec/unit/ridley/middleware/parse_json_spec.rb +14 -14
- data/spec/unit/ridley/mixins/from_file_spec.rb +3 -3
- data/spec/unit/ridley/resource_spec.rb +5 -5
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +21 -21
- data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/data_bag_resource_spec.rb +6 -3
- data/spec/unit/ridley/resources/environment_resource_spec.rb +4 -4
- data/spec/unit/ridley/resources/role_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/sandbox_resource_spec.rb +7 -7
- data/spec/unit/ridley/resources/search_resource_spec.rb +22 -22
- data/spec/unit/ridley/sandbox_uploader_spec.rb +3 -3
- data/spec/unit/ridley_spec.rb +6 -6
- metadata +62 -64
- data/.ruby-version +0 -1
- data/lib/ridley/middleware/gzip.rb +0 -18
- data/spec/unit/ridley/middleware/gzip_spec.rb +0 -59
|
@@ -24,15 +24,15 @@ describe Ridley::SandboxObject do
|
|
|
24
24
|
)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
before { subject.
|
|
27
|
+
before { allow(subject).to receive_messages(resource: resource) }
|
|
28
28
|
|
|
29
29
|
describe "#checksums" do
|
|
30
|
-
|
|
30
|
+
skip
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
describe "#commit" do
|
|
34
34
|
let(:response) { { is_completed: nil} }
|
|
35
|
-
before { resource.
|
|
35
|
+
before { expect(resource).to receive(:commit).with(subject).and_return(response) }
|
|
36
36
|
|
|
37
37
|
context "when the commit is successful" do
|
|
38
38
|
before { response[:is_completed] = true }
|
|
@@ -40,7 +40,7 @@ describe Ridley::SandboxObject do
|
|
|
40
40
|
it "has an 'is_completed' value of true" do
|
|
41
41
|
subject.commit
|
|
42
42
|
|
|
43
|
-
subject.is_completed.
|
|
43
|
+
expect(subject.is_completed).to be_truthy
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -50,7 +50,7 @@ describe Ridley::SandboxObject do
|
|
|
50
50
|
it "has an 'is_completed' value of false" do
|
|
51
51
|
subject.commit
|
|
52
52
|
|
|
53
|
-
subject.is_completed.
|
|
53
|
+
expect(subject.is_completed).to be_falsey
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
end
|
|
@@ -58,7 +58,7 @@ describe Ridley::SandboxObject do
|
|
|
58
58
|
describe "#upload" do
|
|
59
59
|
it "delegates to resource#upload" do
|
|
60
60
|
checksums = double('checksums')
|
|
61
|
-
resource.
|
|
61
|
+
expect(resource).to receive(:upload).with(subject, checksums)
|
|
62
62
|
|
|
63
63
|
subject.upload(checksums)
|
|
64
64
|
end
|
|
@@ -32,9 +32,20 @@ describe Ridley::Client do
|
|
|
32
32
|
subject { described_class.new(options) }
|
|
33
33
|
|
|
34
34
|
describe "parsing the 'server_url' option" do
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
describe '#host' do
|
|
36
|
+
subject { super().host }
|
|
37
|
+
it { is_expected.to eql("api.opscode.com") }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#scheme' do
|
|
41
|
+
subject { super().scheme }
|
|
42
|
+
it { is_expected.to eql("https") }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#path_prefix' do
|
|
46
|
+
subject { super().path_prefix }
|
|
47
|
+
it { is_expected.to eql("/") }
|
|
48
|
+
end
|
|
38
49
|
end
|
|
39
50
|
|
|
40
51
|
describe "with a server_url containing an organization" do
|
|
@@ -43,16 +54,16 @@ describe Ridley::Client do
|
|
|
43
54
|
end
|
|
44
55
|
|
|
45
56
|
it "gets the host data from the server_url" do
|
|
46
|
-
subject.host.
|
|
47
|
-
subject.scheme.
|
|
57
|
+
expect(subject.host).to eql("api.opscode.com")
|
|
58
|
+
expect(subject.scheme).to eql("https")
|
|
48
59
|
end
|
|
49
60
|
|
|
50
61
|
it "takes the organization out of the server_url and assigns it to the organization reader" do
|
|
51
|
-
subject.organization.
|
|
62
|
+
expect(subject.organization).to eql(organization)
|
|
52
63
|
end
|
|
53
64
|
|
|
54
65
|
it "sets the 'path_prefix' of the connection the organization sub URI" do
|
|
55
|
-
subject.path_prefix.
|
|
66
|
+
expect(subject.path_prefix).to eql("/organizations/#{organization}")
|
|
56
67
|
end
|
|
57
68
|
end
|
|
58
69
|
|
|
@@ -94,26 +105,26 @@ describe Ridley::Client do
|
|
|
94
105
|
it "expands the path of the client_key" do
|
|
95
106
|
config[:client_key] = "spec/fixtures/reset.pem"
|
|
96
107
|
|
|
97
|
-
described_class.new(config).client_key[0..4].
|
|
108
|
+
expect(described_class.new(config).client_key[0..4]).not_to eq("spec/")
|
|
98
109
|
end
|
|
99
110
|
|
|
100
111
|
it "accepts a client key as a string" do
|
|
101
112
|
key = File.read(fixtures_path.join("reset.pem").to_s)
|
|
102
113
|
config[:client_key] = key.dup
|
|
103
|
-
described_class.new(config).client_key.
|
|
114
|
+
expect(described_class.new(config).client_key).to eq(key)
|
|
104
115
|
end
|
|
105
116
|
|
|
106
117
|
it "assigns a 'chef_version' attribute from the given 'chef_version' option" do
|
|
107
|
-
described_class.new(config).chef_version.
|
|
118
|
+
expect(described_class.new(config).chef_version).to eql("10.24.0-01")
|
|
108
119
|
end
|
|
109
120
|
end
|
|
110
121
|
|
|
111
122
|
describe "::open" do
|
|
112
123
|
it "instantiates a new connection, yields to it, and terminates it" do
|
|
113
124
|
new_instance = double(alive?: true)
|
|
114
|
-
described_class.
|
|
115
|
-
new_instance.
|
|
116
|
-
new_instance.
|
|
125
|
+
expect(described_class).to receive(:new).and_return(new_instance)
|
|
126
|
+
expect(new_instance).to receive(:hello)
|
|
127
|
+
expect(new_instance).to receive(:terminate)
|
|
117
128
|
|
|
118
129
|
described_class.open do |f|
|
|
119
130
|
f.hello
|
|
@@ -126,18 +137,45 @@ describe Ridley::Client do
|
|
|
126
137
|
|
|
127
138
|
subject { instance }
|
|
128
139
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
describe '#client' do
|
|
141
|
+
subject { super().client }
|
|
142
|
+
it { is_expected.to be_a(Ridley::ClientResource) }
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe '#cookbook' do
|
|
146
|
+
subject { super().cookbook }
|
|
147
|
+
it { is_expected.to be_a(Ridley::CookbookResource) }
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe '#data_bag' do
|
|
151
|
+
subject { super().data_bag }
|
|
152
|
+
it { is_expected.to be_a(Ridley::DataBagResource) }
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
describe '#environment' do
|
|
156
|
+
subject { super().environment }
|
|
157
|
+
it { is_expected.to be_a(Ridley::EnvironmentResource) }
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
describe '#node' do
|
|
161
|
+
subject { super().node }
|
|
162
|
+
it { is_expected.to be_a(Ridley::NodeResource) }
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
describe '#role' do
|
|
166
|
+
subject { super().role }
|
|
167
|
+
it { is_expected.to be_a(Ridley::RoleResource) }
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
describe '#sandbox' do
|
|
171
|
+
subject { super().sandbox }
|
|
172
|
+
it { is_expected.to be_a(Ridley::SandboxResource) }
|
|
173
|
+
end
|
|
136
174
|
|
|
137
175
|
describe "#encrypted_data_bag_secret" do
|
|
138
176
|
subject { instance.encrypted_data_bag_secret }
|
|
139
177
|
|
|
140
|
-
it {
|
|
178
|
+
it { is_expected.to be_a(String) }
|
|
141
179
|
|
|
142
180
|
context "when a encrypted_data_bag_secret_path is not provided" do
|
|
143
181
|
before(:each) do
|
|
@@ -18,7 +18,7 @@ describe Ridley::Connection do
|
|
|
18
18
|
expect {
|
|
19
19
|
subject.get('organizations/vialstudios')
|
|
20
20
|
}.to raise_error
|
|
21
|
-
a_request(:get, "https://api.opscode.com/organizations/vialstudios").
|
|
21
|
+
expect(a_request(:get, "https://api.opscode.com/organizations/vialstudios")).to have_been_made.times(6)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
context "given a configured count of two (2) retries" do
|
|
@@ -31,7 +31,7 @@ describe Ridley::Connection do
|
|
|
31
31
|
subject.get('organizations/vialstudios')
|
|
32
32
|
}.to raise_error
|
|
33
33
|
|
|
34
|
-
a_request(:get, "https://api.opscode.com/organizations/vialstudios").
|
|
34
|
+
expect(a_request(:get, "https://api.opscode.com/organizations/vialstudios")).to have_been_made.times(3)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -40,13 +40,13 @@ describe Ridley::Connection do
|
|
|
40
40
|
it "returns :foss if the organization is not set" do
|
|
41
41
|
subject.stub(:organization).and_return(nil)
|
|
42
42
|
|
|
43
|
-
subject.api_type.
|
|
43
|
+
expect(subject.api_type).to eql(:foss)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "returns :hosted if the organization is set" do
|
|
47
47
|
subject.stub(:organization).and_return("vialstudios")
|
|
48
48
|
|
|
49
|
-
subject.api_type.
|
|
49
|
+
expect(subject.api_type).to eql(:hosted)
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
@@ -62,17 +62,17 @@ describe Ridley::Connection do
|
|
|
62
62
|
it "creates a destination file on disk" do
|
|
63
63
|
subject.stream(target, destination)
|
|
64
64
|
|
|
65
|
-
File.exist?(destination).
|
|
65
|
+
expect(File.exist?(destination)).to be_truthy
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "returns true when the file was copied" do
|
|
69
|
-
expect(subject.stream(target, destination)).to
|
|
69
|
+
expect(subject.stream(target, destination)).to be_truthy
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it "contains the contents of the response body" do
|
|
73
73
|
subject.stream(target, destination)
|
|
74
74
|
|
|
75
|
-
File.read(destination).
|
|
75
|
+
expect(File.read(destination)).to include(contents)
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
end
|
|
@@ -18,7 +18,7 @@ describe Ridley::Errors do
|
|
|
18
18
|
it "adds an item to the error map" do
|
|
19
19
|
subject.register_error(400)
|
|
20
20
|
|
|
21
|
-
subject.error_map.
|
|
21
|
+
expect(subject.error_map.size).to eq(1)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it "adds a key of the given status code with a value of the class inheriting from HTTPError" do
|
|
@@ -26,7 +26,7 @@ describe Ridley::Errors do
|
|
|
26
26
|
register_error(400)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
subject.error_map[400].
|
|
29
|
+
expect(subject.error_map[400]).to eql(RidleyTestHTTPError)
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -35,7 +35,7 @@ describe Ridley::Errors do
|
|
|
35
35
|
subject { Ridley::Errors::HTTPError.new(:body => "<html><body><h1>Redirected</h1></body></html>") }
|
|
36
36
|
|
|
37
37
|
it "has an HTML body" do
|
|
38
|
-
subject.message.
|
|
38
|
+
expect(subject.message).to eq("<html><body><h1>Redirected</h1></body></html>")
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
end
|
|
@@ -16,7 +16,7 @@ describe Ridley::Middleware::ChefAuth do
|
|
|
16
16
|
host: "https://api.opscode.com",
|
|
17
17
|
path: "/something.file"
|
|
18
18
|
}
|
|
19
|
-
subject.authentication_headers(client_name, client_key, options).
|
|
19
|
+
expect(subject.authentication_headers(client_name, client_key, options)).to be_a(Hash)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
context "when the :client_key is an actual key" do
|
|
@@ -28,7 +28,7 @@ describe Ridley::Middleware::ChefAuth do
|
|
|
28
28
|
host: "https://api.opscode.com",
|
|
29
29
|
path: "/something.file"
|
|
30
30
|
}
|
|
31
|
-
subject.authentication_headers(client_name, client_key, options).
|
|
31
|
+
expect(subject.authentication_headers(client_name, client_key, options)).to be_a(Hash)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
|
@@ -11,33 +11,33 @@ describe Ridley::Middleware::ChefResponse do
|
|
|
11
11
|
|
|
12
12
|
it "returns true if response status between 200 and 210" do
|
|
13
13
|
(200..210).each do |code|
|
|
14
|
-
env.
|
|
14
|
+
expect(env).to receive(:[]).with(:status).and_return(code)
|
|
15
15
|
|
|
16
|
-
subject.success?(env).
|
|
16
|
+
expect(subject.success?(env)).to be_truthy
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "returns false if response status is in the 300 range" do
|
|
21
21
|
(300..399).each do |code|
|
|
22
|
-
env.
|
|
22
|
+
expect(env).to receive(:[]).with(:status).and_return(code)
|
|
23
23
|
|
|
24
|
-
subject.success?(env).
|
|
24
|
+
expect(subject.success?(env)).to be_falsey
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "returns false if response status is in the 400 range" do
|
|
29
29
|
(400..499).each do |code|
|
|
30
|
-
env.
|
|
30
|
+
expect(env).to receive(:[]).with(:status).and_return(code)
|
|
31
31
|
|
|
32
|
-
subject.success?(env).
|
|
32
|
+
expect(subject.success?(env)).to be_falsey
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "returns false if response status is in the 500 range" do
|
|
37
37
|
(500..599).each do |code|
|
|
38
|
-
env.
|
|
38
|
+
expect(env).to receive(:[]).with(:status).and_return(code)
|
|
39
39
|
|
|
40
|
-
subject.success?(env).
|
|
40
|
+
expect(subject.success?(env)).to be_falsey
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -117,15 +117,15 @@ describe Ridley::Middleware::ChefResponse do
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
it "raises a Ridley::Errors::HTTPBadRequest" do
|
|
120
|
-
|
|
120
|
+
expect {
|
|
121
121
|
subject.get('cookbooks')
|
|
122
|
-
}.
|
|
122
|
+
}.to raise_error(Ridley::Errors::HTTPBadRequest)
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
it "should have the body of the response as the error's message" do
|
|
126
|
-
|
|
126
|
+
expect {
|
|
127
127
|
subject.get('cookbooks')
|
|
128
|
-
}.
|
|
128
|
+
}.to raise_error("errors: '400 - Bad Request: Valid X-CHEF-VERSION header is required.'")
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
|
|
@@ -135,15 +135,15 @@ describe Ridley::Middleware::ChefResponse do
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it "raises a Ridley::Errors::HTTPUnauthorized" do
|
|
138
|
-
|
|
138
|
+
expect {
|
|
139
139
|
subject.get('cookbooks')
|
|
140
|
-
}.
|
|
140
|
+
}.to raise_error(Ridley::Errors::HTTPUnauthorized)
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
it "should have the body of the response as the error's message" do
|
|
144
|
-
|
|
144
|
+
expect {
|
|
145
145
|
subject.get('cookbooks')
|
|
146
|
-
}.
|
|
146
|
+
}.to raise_error("errors: '401 - Unauthorized. You must properly authenticate your API requests!'")
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -153,15 +153,15 @@ describe Ridley::Middleware::ChefResponse do
|
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
it "raises a Ridley::Errors::HTTPForbidden" do
|
|
156
|
-
|
|
156
|
+
expect {
|
|
157
157
|
subject.get('cookbooks')
|
|
158
|
-
}.
|
|
158
|
+
}.to raise_error(Ridley::Errors::HTTPForbidden)
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
it "should have the body of the response as the error's message" do
|
|
162
|
-
|
|
162
|
+
expect {
|
|
163
163
|
subject.get('cookbooks')
|
|
164
|
-
}.
|
|
164
|
+
}.to raise_error("errors: '403 - Forbidden.'")
|
|
165
165
|
end
|
|
166
166
|
end
|
|
167
167
|
|
|
@@ -171,15 +171,15 @@ describe Ridley::Middleware::ChefResponse do
|
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
it "raises a Ridley::Errors::HTTPNotFound" do
|
|
174
|
-
|
|
174
|
+
expect {
|
|
175
175
|
subject.get('not_existant_route')
|
|
176
|
-
}.
|
|
176
|
+
}.to raise_error(Ridley::Errors::HTTPNotFound)
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
it "should have the body of the response as the error's message" do
|
|
180
|
-
|
|
180
|
+
expect {
|
|
181
181
|
subject.get('not_existant_route')
|
|
182
|
-
}.
|
|
182
|
+
}.to raise_error(Ridley::Errors::HTTPNotFound, "errors: 'No routes match the request: /organizations/vialstudios/cookbookss/not_existant'")
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
|
|
@@ -189,15 +189,15 @@ describe Ridley::Middleware::ChefResponse do
|
|
|
189
189
|
end
|
|
190
190
|
|
|
191
191
|
it "raises a Ridley::Errors::HTTPForbidden" do
|
|
192
|
-
|
|
192
|
+
expect {
|
|
193
193
|
subject.get('cookbooks')
|
|
194
|
-
}.
|
|
194
|
+
}.to raise_error(Ridley::Errors::HTTPConflict)
|
|
195
195
|
end
|
|
196
196
|
|
|
197
197
|
it "should have the body of the response as the error's message" do
|
|
198
|
-
|
|
198
|
+
expect {
|
|
199
199
|
subject.get('cookbooks')
|
|
200
|
-
}.
|
|
200
|
+
}.to raise_error("errors: '409 - Conflict.'")
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
203
|
|
|
@@ -207,7 +207,7 @@ describe Ridley::Middleware::ChefResponse do
|
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
it "returns a body containing a hash" do
|
|
210
|
-
subject.get('roles/reset').env[:body].
|
|
210
|
+
expect(subject.get('roles/reset').env[:body]).to be_a(Hash)
|
|
211
211
|
end
|
|
212
212
|
end
|
|
213
213
|
end
|
|
@@ -9,42 +9,42 @@ describe Ridley::Middleware::ParseJson do
|
|
|
9
9
|
describe "::response_type" do
|
|
10
10
|
it "returns the first element of the response content-type" do
|
|
11
11
|
env = double('env')
|
|
12
|
-
env.
|
|
12
|
+
allow(env).to receive(:[]).with(:response_headers).and_return(
|
|
13
13
|
'content-type' => 'text/html; charset=utf-8'
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
subject.response_type(env).
|
|
16
|
+
expect(subject.response_type(env)).to eql("text/html")
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
describe "::json_response?" do
|
|
21
21
|
it "returns true if the value of content-type includes 'application/json' and the body looks like JSON" do
|
|
22
22
|
env = double('env')
|
|
23
|
-
env.
|
|
23
|
+
allow(env).to receive(:[]).with(:response_headers).and_return(
|
|
24
24
|
'content-type' => 'application/json; charset=utf8'
|
|
25
25
|
)
|
|
26
|
-
subject.
|
|
26
|
+
expect(subject).to receive(:looks_like_json?).with(env).and_return(true)
|
|
27
27
|
|
|
28
|
-
subject.json_response?(env).
|
|
28
|
+
expect(subject.json_response?(env)).to be_truthy
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "returns false if the value of content-type includes 'application/json' but the body does not look like JSON" do
|
|
32
32
|
env = double('env')
|
|
33
|
-
env.
|
|
33
|
+
allow(env).to receive(:[]).with(:response_headers).and_return(
|
|
34
34
|
'content-type' => 'application/json; charset=utf8'
|
|
35
35
|
)
|
|
36
|
-
subject.
|
|
36
|
+
expect(subject).to receive(:looks_like_json?).with(env).and_return(false)
|
|
37
37
|
|
|
38
|
-
subject.json_response?(env).
|
|
38
|
+
expect(subject.json_response?(env)).to be_falsey
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "returns false if the value of content-type does not include 'application/json'" do
|
|
42
42
|
env = double('env')
|
|
43
|
-
env.
|
|
43
|
+
allow(env).to receive(:[]).with(:response_headers).and_return(
|
|
44
44
|
'content-type' => 'text/plain'
|
|
45
45
|
)
|
|
46
46
|
|
|
47
|
-
subject.json_response?(env).
|
|
47
|
+
expect(subject.json_response?(env)).to be_falsey
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -52,15 +52,15 @@ describe Ridley::Middleware::ParseJson do
|
|
|
52
52
|
let(:env) { double('env') }
|
|
53
53
|
|
|
54
54
|
it "returns true if the given string contains JSON brackets" do
|
|
55
|
-
env.
|
|
55
|
+
allow(env).to receive(:[]).with(:body).and_return("{\"name\":\"jamie\"}")
|
|
56
56
|
|
|
57
|
-
subject.looks_like_json?(env).
|
|
57
|
+
expect(subject.looks_like_json?(env)).to be_truthy
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it "returns false if the given string does not contain JSON brackets" do
|
|
61
|
-
env.
|
|
61
|
+
allow(env).to receive(:[]).with(:body).and_return("name")
|
|
62
62
|
|
|
63
|
-
subject.looks_like_json?(env).
|
|
63
|
+
expect(subject.looks_like_json?(env)).to be_falsey
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -7,9 +7,9 @@ module Ridley
|
|
|
7
7
|
let(:instance) { Class.new { include Ridley::Mixin::FromFile }.new }
|
|
8
8
|
|
|
9
9
|
before do
|
|
10
|
-
File.
|
|
11
|
-
File.
|
|
12
|
-
IO.
|
|
10
|
+
allow(File).to receive(:exists?).and_return(true)
|
|
11
|
+
allow(File).to receive(:readable?).and_return(true)
|
|
12
|
+
allow(IO).to receive(:read).and_return('invalid Ruby code')
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'raises a FromFileParserError' do
|
|
@@ -22,7 +22,7 @@ describe Ridley::Resource do
|
|
|
22
22
|
it "sets the resource_path attr on the class" do
|
|
23
23
|
subject.set_resource_path("environments")
|
|
24
24
|
|
|
25
|
-
subject.resource_path.
|
|
25
|
+
expect(subject.resource_path).to eql("environments")
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -31,7 +31,7 @@ describe Ridley::Resource do
|
|
|
31
31
|
before { subject.set_resource_path(nil) }
|
|
32
32
|
|
|
33
33
|
it "returns the representation's chef type" do
|
|
34
|
-
subject.resource_path.
|
|
34
|
+
expect(subject.resource_path).to eql(representation.chef_type)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -40,7 +40,7 @@ describe Ridley::Resource do
|
|
|
40
40
|
before { subject.set_resource_path(set_path) }
|
|
41
41
|
|
|
42
42
|
it "returns the set value" do
|
|
43
|
-
subject.resource_path.
|
|
43
|
+
expect(subject.resource_path).to eql(set_path)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
end
|
|
@@ -97,7 +97,7 @@ describe Ridley::Resource do
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "returns nil" do
|
|
100
|
-
subject.find(id).
|
|
100
|
+
expect(subject.find(id)).to be_nil
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
end
|
|
@@ -135,7 +135,7 @@ describe Ridley::Resource do
|
|
|
135
135
|
|
|
136
136
|
describe "::delete_all" do
|
|
137
137
|
it "sends a delete request for every object in the collection" do
|
|
138
|
-
|
|
138
|
+
skip
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
|
|
@@ -42,7 +42,7 @@ describe Ridley::CookbookResource do
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "returns the latest version" do
|
|
45
|
-
subject.latest_version(name).
|
|
45
|
+
expect(subject.latest_version(name)).to eql("3.0.0")
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
|
@@ -58,16 +58,16 @@ describe Ridley::CookbookResource do
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it "returns an array" do
|
|
61
|
-
subject.versions(name).
|
|
61
|
+
expect(subject.versions(name)).to be_a(Array)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it "contains a version string for each cookbook version available" do
|
|
65
65
|
result = subject.versions(name)
|
|
66
66
|
|
|
67
|
-
result.
|
|
68
|
-
result.
|
|
69
|
-
result.
|
|
70
|
-
result.
|
|
67
|
+
expect(result.size).to eq(3)
|
|
68
|
+
expect(result).to include("1.0.0")
|
|
69
|
+
expect(result).to include("1.1.0")
|
|
70
|
+
expect(result).to include("1.2.0")
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
@@ -90,11 +90,11 @@ describe Ridley::CookbookResource do
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
it "returns a CookbookObject" do
|
|
93
|
-
subject.satisfy(name, ">= 2.0.0").
|
|
93
|
+
expect(subject.satisfy(name, ">= 2.0.0")).to be_a(Ridley::CookbookObject)
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
it "is the best solution" do
|
|
97
|
-
subject.satisfy(name, ">= 2.0.0").version.
|
|
97
|
+
expect(subject.satisfy(name, ">= 2.0.0").version).to eql("3.0.0")
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
@@ -102,7 +102,7 @@ describe Ridley::CookbookResource do
|
|
|
102
102
|
before { chef_cookbook(name, "1.0.0") }
|
|
103
103
|
|
|
104
104
|
it "returns nil" do
|
|
105
|
-
subject.satisfy(name, ">= 2.0.0").
|
|
105
|
+
expect(subject.satisfy(name, ">= 2.0.0")).to be_nil
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
@@ -126,20 +126,20 @@ describe Ridley::CookbookResource do
|
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
it 'does not include files that are ignored' do
|
|
129
|
-
# These are the
|
|
129
|
+
# These are the MD5s for the files. It's not possible to check that
|
|
130
130
|
# the ignored files weren't uploaded, so we just check that the
|
|
131
131
|
# non-ignored files are the ONLY thing uploaded
|
|
132
132
|
sandbox_resource.should_receive(:create).with([
|
|
133
|
-
"211a3a8798d4acd424af15ff8a2e28a5",
|
|
134
|
-
"
|
|
135
|
-
"75077ba33d2887cc1746d1ef716bf8b7",
|
|
136
|
-
"7b1ebd2ff580ca9dc46fb27ec1653bf2",
|
|
137
|
-
"84e12365e6f4ebe7db6a0e6a92473b16",
|
|
138
|
-
"a39eb80def9804f4b118099697cc2cd2",
|
|
139
|
-
"b70ba735f3af47e5d6fc71b91775b34c",
|
|
140
|
-
"cafb6869fca13f5c36f24a60de8fb982",
|
|
141
|
-
"dbf3a6c4ab68a86172be748aced9f46e",
|
|
142
|
-
"dc6461b5da25775f3ef6a9cc1f6cff9f",
|
|
133
|
+
"211a3a8798d4acd424af15ff8a2e28a5",
|
|
134
|
+
"64ac6346672c6bea4ade983e3d58cd14",
|
|
135
|
+
"75077ba33d2887cc1746d1ef716bf8b7",
|
|
136
|
+
"7b1ebd2ff580ca9dc46fb27ec1653bf2",
|
|
137
|
+
"84e12365e6f4ebe7db6a0e6a92473b16",
|
|
138
|
+
"a39eb80def9804f4b118099697cc2cd2",
|
|
139
|
+
"b70ba735f3af47e5d6fc71b91775b34c",
|
|
140
|
+
"cafb6869fca13f5c36f24a60de8fb982",
|
|
141
|
+
"dbf3a6c4ab68a86172be748aced9f46e",
|
|
142
|
+
"dc6461b5da25775f3ef6a9cc1f6cff9f",
|
|
143
143
|
"e9a2e24281cfbd6be0a6b1af3b6d277e"
|
|
144
144
|
]).and_return(sandbox)
|
|
145
145
|
|
|
@@ -148,6 +148,6 @@ describe Ridley::CookbookResource do
|
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
describe "#update" do
|
|
151
|
-
|
|
151
|
+
skip
|
|
152
152
|
end
|
|
153
153
|
end
|