ridley 0.10.2 → 0.11.0.rc1
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.
- data/README.md +147 -216
- data/lib/ridley.rb +2 -0
- data/lib/ridley/bootstrap_bindings/unix_template_binding.rb +21 -25
- data/lib/ridley/bootstrap_bindings/windows_template_binding.rb +29 -34
- data/lib/ridley/bootstrapper.rb +2 -2
- data/lib/ridley/bootstrapper/context.rb +5 -5
- data/lib/ridley/chef.rb +0 -1
- data/lib/ridley/chef/cookbook.rb +0 -9
- data/lib/ridley/chef_object.rb +128 -0
- data/lib/ridley/chef_objects.rb +3 -0
- data/lib/ridley/chef_objects/client_object.rb +55 -0
- data/lib/ridley/chef_objects/cookbook_object.rb +190 -0
- data/lib/ridley/chef_objects/data_bag_item_obect.rb +104 -0
- data/lib/ridley/chef_objects/data_bag_object.rb +31 -0
- data/lib/ridley/chef_objects/environment_object.rb +59 -0
- data/lib/ridley/chef_objects/node_object.rb +161 -0
- data/lib/ridley/chef_objects/role_object.rb +62 -0
- data/lib/ridley/chef_objects/sandbox_object.rb +58 -0
- data/lib/ridley/client.rb +76 -45
- data/lib/ridley/connection.rb +1 -1
- data/lib/ridley/errors.rb +8 -1
- data/lib/ridley/host_connector.rb +26 -6
- data/lib/ridley/host_connector/ssh.rb +3 -3
- data/lib/ridley/host_connector/ssh/worker.rb +7 -9
- data/lib/ridley/host_connector/winrm/worker.rb +4 -5
- data/lib/ridley/mixin/bootstrap_binding.rb +1 -12
- data/lib/ridley/resource.rb +51 -171
- data/lib/ridley/resources/client_resource.rb +18 -68
- data/lib/ridley/resources/cookbook_resource.rb +181 -381
- data/lib/ridley/resources/data_bag_item_resource.rb +55 -161
- data/lib/ridley/resources/data_bag_resource.rb +20 -61
- data/lib/ridley/resources/environment_resource.rb +9 -64
- data/lib/ridley/resources/node_resource.rb +135 -311
- data/lib/ridley/resources/role_resource.rb +1 -57
- data/lib/ridley/resources/sandbox_resource.rb +80 -65
- data/lib/ridley/resources/search_resource.rb +99 -0
- data/lib/ridley/sandbox_uploader.rb +12 -52
- data/lib/ridley/version.rb +1 -1
- data/spec/acceptance/bootstrapping_spec.rb +1 -1
- data/spec/acceptance/client_resource_spec.rb +15 -37
- data/spec/acceptance/data_bag_item_resource_spec.rb +8 -14
- data/spec/acceptance/data_bag_resource_spec.rb +1 -1
- data/spec/acceptance/environment_resource_spec.rb +13 -22
- data/spec/acceptance/node_resource_spec.rb +10 -29
- data/spec/acceptance/role_resource_spec.rb +14 -13
- data/spec/acceptance/sandbox_resource_spec.rb +2 -2
- data/spec/support/shared_examples/ridley_resource.rb +2 -23
- data/spec/unit/ridley/bootstrap_bindings/unix_template_binding_spec.rb +3 -4
- data/spec/unit/ridley/bootstrap_bindings/windows_template_binding_spec.rb +3 -5
- data/spec/unit/ridley/bootstrapper/context_spec.rb +2 -3
- data/spec/unit/ridley/bootstrapper_spec.rb +1 -1
- data/spec/unit/ridley/chef_object_spec.rb +240 -0
- data/spec/unit/ridley/chef_objects/client_object_spec.rb +11 -0
- data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +93 -0
- data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +74 -0
- data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +9 -0
- data/spec/unit/ridley/chef_objects/environment_object_spec.rb +57 -0
- data/spec/unit/ridley/chef_objects/node_object_spec.rb +252 -0
- data/spec/unit/ridley/chef_objects/role_object_spec.rb +57 -0
- data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +66 -0
- data/spec/unit/ridley/client_spec.rb +51 -51
- data/spec/unit/ridley/host_connector/ssh/worker_spec.rb +4 -4
- data/spec/unit/ridley/host_connector/ssh_spec.rb +26 -24
- data/spec/unit/ridley/host_connector/winrm/worker_spec.rb +3 -4
- data/spec/unit/ridley/host_connector/winrm_spec.rb +4 -4
- data/spec/unit/ridley/host_connector_spec.rb +40 -3
- data/spec/unit/ridley/mixin/bootstrap_binding_spec.rb +1 -1
- data/spec/unit/ridley/resource_spec.rb +81 -109
- data/spec/unit/ridley/resources/client_resource_spec.rb +18 -33
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +56 -230
- data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +2 -57
- data/spec/unit/ridley/resources/data_bag_resource_spec.rb +12 -7
- data/spec/unit/ridley/resources/environment_resource_spec.rb +10 -118
- data/spec/unit/ridley/resources/node_resource_spec.rb +83 -394
- data/spec/unit/ridley/resources/role_resource_spec.rb +2 -56
- data/spec/unit/ridley/resources/sandbox_resource_spec.rb +139 -136
- data/spec/unit/ridley/resources/search_resource_spec.rb +234 -0
- data/spec/unit/ridley/sandbox_uploader_spec.rb +13 -58
- metadata +36 -17
- data/lib/ridley/chef/chefignore.rb +0 -76
- data/lib/ridley/resources/encrypted_data_bag_item_resource.rb +0 -55
- data/lib/ridley/resources/search.rb +0 -101
- data/spec/fixtures/chefignore +0 -8
- data/spec/unit/ridley/chef/chefignore_spec.rb +0 -40
- data/spec/unit/ridley/resources/search_spec.rb +0 -221
@@ -7,7 +7,7 @@ describe Ridley::BootstrapBinding do
|
|
7
7
|
server_url: "https://api.opscode.com/organizations/vialstudios",
|
8
8
|
validator_client: "chef-validator",
|
9
9
|
validator_path: fixtures_path.join("reset.pem").to_s,
|
10
|
-
|
10
|
+
encrypted_data_bag_secret: File.read(fixtures_path.join("reset.pem")),
|
11
11
|
chef_version: "11.4.0"
|
12
12
|
}
|
13
13
|
end
|
@@ -1,33 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ridley::Resource do
|
4
|
-
let(:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
let(:representation) do
|
5
|
+
Class.new(Ridley::ChefObject) do
|
6
|
+
set_chef_id "id"
|
7
|
+
set_chef_type "thing"
|
8
|
+
set_chef_json_class "Chef::Thing"
|
9
9
|
end
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
it "mass assigns the given attributes" do
|
15
|
-
new_attrs = {
|
16
|
-
name: "a name"
|
17
|
-
}
|
18
|
-
|
19
|
-
subject.any_instance.should_receive(:mass_assign).with(new_attrs)
|
20
|
-
subject.new(connection, new_attrs)
|
21
|
-
end
|
12
|
+
let(:resource_class) do
|
13
|
+
Class.new(Ridley::Resource) do
|
14
|
+
set_resource_path "rspecs"
|
22
15
|
end
|
16
|
+
end
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
subject.set_chef_type("environment")
|
27
|
-
|
28
|
-
subject.chef_type.should eql("environment")
|
29
|
-
end
|
30
|
-
end
|
18
|
+
describe "ClassMethods" do
|
19
|
+
subject { resource_class }
|
31
20
|
|
32
21
|
describe "::set_resource_path" do
|
33
22
|
it "sets the resource_path attr on the class" do
|
@@ -37,126 +26,109 @@ describe Ridley::Resource do
|
|
37
26
|
end
|
38
27
|
end
|
39
28
|
|
40
|
-
describe "::set_chef_json_class" do
|
41
|
-
it "sets the chef_json_class attr on the class" do
|
42
|
-
subject.set_chef_json_class("Chef::Environment")
|
43
|
-
|
44
|
-
subject.chef_json_class.should eql("Chef::Environment")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "::set_chef_id" do
|
49
|
-
it "sets the chef_id attribute on the class" do
|
50
|
-
subject.set_chef_id(:environment)
|
51
|
-
|
52
|
-
subject.chef_id.should eql(:environment)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
29
|
describe "::resource_path" do
|
57
|
-
|
58
|
-
subject.
|
59
|
-
end
|
60
|
-
end
|
30
|
+
context "when not explicitly set" do
|
31
|
+
before { subject.set_resource_path(nil) }
|
61
32
|
|
62
|
-
|
63
|
-
|
64
|
-
|
33
|
+
it "returns the representation's chef type, pluralized" do
|
34
|
+
subject.resource_path.should eql(representation.chef_type.pluralize)
|
35
|
+
end
|
65
36
|
end
|
66
|
-
end
|
67
37
|
|
68
|
-
|
69
|
-
|
70
|
-
subject.
|
71
|
-
end
|
72
|
-
end
|
38
|
+
context "when explicitly set" do
|
39
|
+
let(:set_path) { "hello" }
|
40
|
+
before { subject.set_resource_path(set_path) }
|
73
41
|
|
74
|
-
|
75
|
-
|
76
|
-
|
42
|
+
it "returns the set value" do
|
43
|
+
subject.resource_path.should eql(set_path)
|
44
|
+
end
|
77
45
|
end
|
78
46
|
end
|
79
47
|
end
|
80
48
|
|
81
|
-
|
82
|
-
|
49
|
+
let(:connection) { double('chef-connection') }
|
50
|
+
let(:response) { double('chef-response', body: Hash.new) }
|
51
|
+
|
52
|
+
subject { resource_class.new(double('registry')) }
|
53
|
+
|
54
|
+
before do
|
55
|
+
resource_class.stub(representation: representation)
|
56
|
+
subject.stub(connection: connection)
|
83
57
|
end
|
84
58
|
|
85
|
-
describe "
|
86
|
-
|
87
|
-
|
88
|
-
set_chef_id "name"
|
59
|
+
describe "::all" do
|
60
|
+
it "sends GET to /{resource_path}" do
|
61
|
+
connection.should_receive(:get).with(subject.class.resource_path).and_return(response)
|
89
62
|
|
90
|
-
|
91
|
-
attribute "other_extra"
|
92
|
-
attribute "extra"
|
93
|
-
end
|
63
|
+
subject.all
|
94
64
|
end
|
65
|
+
end
|
95
66
|
|
96
|
-
|
97
|
-
let(:
|
67
|
+
describe "::find" do
|
68
|
+
let(:id) { "some_id" }
|
98
69
|
|
99
|
-
|
100
|
-
|
101
|
-
one.mass_assign(name: "reset", other_extra: "stuff")
|
102
|
-
two.mass_assign(name: "reset", extra: "stuff")
|
103
|
-
end
|
70
|
+
it "sends GET to /{resource_path}/{id} where {id} is the given ID" do
|
71
|
+
connection.should_receive(:get).with("#{subject.class.resource_path}/#{id}").and_return(response)
|
104
72
|
|
105
|
-
|
106
|
-
one.should be_eql(two)
|
107
|
-
end
|
73
|
+
subject.find(id)
|
108
74
|
end
|
109
75
|
|
110
|
-
context "
|
111
|
-
before
|
112
|
-
|
113
|
-
|
76
|
+
context "when the resource is not found" do
|
77
|
+
before do
|
78
|
+
connection.should_receive(:get).with("#{subject.class.resource_path}/#{id}").
|
79
|
+
and_raise(Ridley::Errors::HTTPNotFound.new({}))
|
114
80
|
end
|
115
81
|
|
116
|
-
it "
|
117
|
-
|
82
|
+
it "returns nil" do
|
83
|
+
subject.find(id).should be_nil
|
118
84
|
end
|
119
85
|
end
|
120
86
|
end
|
121
87
|
|
122
|
-
describe "
|
123
|
-
|
124
|
-
|
125
|
-
|
88
|
+
describe "::create" do
|
89
|
+
let(:attrs) do
|
90
|
+
{
|
91
|
+
first_name: "jamie",
|
92
|
+
last_name: "winsor"
|
93
|
+
}
|
94
|
+
end
|
126
95
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
96
|
+
it "sends a post request to the given client using the includer's resource_path" do
|
97
|
+
connection.should_receive(:post).with(subject.class.resource_path, duck_type(:to_json)).and_return(response)
|
98
|
+
|
99
|
+
subject.create(attrs)
|
131
100
|
end
|
101
|
+
end
|
132
102
|
|
133
|
-
|
134
|
-
|
103
|
+
describe "::delete" do
|
104
|
+
it "sends a delete request to the given client using the includer's resource_path for the given string" do
|
105
|
+
connection.should_receive(:delete).with("#{subject.class.resource_path}/ridley-test").and_return(response)
|
135
106
|
|
136
|
-
|
137
|
-
|
138
|
-
one.mass_assign(name: "reset", other_extra: "stuff")
|
139
|
-
two.mass_assign(name: "reset", extra: "stuff")
|
107
|
+
subject.delete("ridley-test")
|
108
|
+
end
|
140
109
|
|
141
|
-
|
142
|
-
|
110
|
+
it "accepts an object that responds to 'chef_id'" do
|
111
|
+
object = double("obj")
|
112
|
+
object.stub(:chef_id) { "hello" }
|
113
|
+
connection.should_receive(:delete).with("#{subject.class.resource_path}/#{object.chef_id}").and_return(response)
|
143
114
|
|
144
|
-
|
145
|
-
nodes.uniq.should have(1).item
|
146
|
-
end
|
115
|
+
subject.delete( object)
|
147
116
|
end
|
117
|
+
end
|
148
118
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
119
|
+
describe "::delete_all" do
|
120
|
+
it "sends a delete request for every object in the collection" do
|
121
|
+
pending
|
122
|
+
end
|
123
|
+
end
|
153
124
|
|
154
|
-
|
155
|
-
|
125
|
+
describe "::update" do
|
126
|
+
it "sends a put request to the given client using the includer's resource_path with the given object" do
|
127
|
+
object = subject.new(name: "hello")
|
128
|
+
connection.should_receive(:put).
|
129
|
+
with("#{subject.class.resource_path}/#{object.chef_id}", duck_type(:to_json)).and_return(response)
|
156
130
|
|
157
|
-
|
158
|
-
nodes.uniq.should have(2).item
|
159
|
-
end
|
131
|
+
subject.update(object)
|
160
132
|
end
|
161
133
|
end
|
162
134
|
end
|
@@ -1,47 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ridley::ClientResource do
|
4
|
-
|
4
|
+
subject { described_class.new(double('registry')) }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
subject { Ridley::ClientResource }
|
10
|
-
|
11
|
-
describe "::regenerate_key" do
|
12
|
-
let(:client) { double('client', name: "ridley-test") }
|
6
|
+
describe "#regenerate_key" do
|
7
|
+
let(:client_id) { "rspec-client" }
|
8
|
+
before { subject.stub(find: nil) }
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
subject.regenerate_key(connection, "ridley-test")
|
19
|
-
end
|
10
|
+
context "when a client with the given ID exists" do
|
11
|
+
let(:client) { double('chef-client') }
|
12
|
+
before { subject.should_receive(:find).with(client_id).and_return(client) }
|
20
13
|
|
21
|
-
it "
|
22
|
-
client.should_receive(:
|
23
|
-
subject.should_receive(:
|
14
|
+
it "sets the private key to true and updates the client" do
|
15
|
+
client.should_receive(:private_key=).with(true)
|
16
|
+
subject.should_receive(:update).with(client)
|
24
17
|
|
25
|
-
subject.regenerate_key(
|
18
|
+
subject.regenerate_key(client_id)
|
26
19
|
end
|
27
20
|
end
|
28
|
-
end
|
29
|
-
|
30
|
-
subject do
|
31
|
-
Ridley::ClientResource.new(connection, name: "ridley-test", admin: false)
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#regenerate_key" do
|
35
|
-
it "returns true if successful" do
|
36
|
-
subject.should_receive(:save).and_return(true)
|
37
|
-
|
38
|
-
subject.regenerate_key.should be_true
|
39
|
-
end
|
40
21
|
|
41
|
-
|
42
|
-
subject.should_receive(:
|
22
|
+
context "when a client with the given ID does not exist" do
|
23
|
+
before { subject.should_receive(:find).with(client_id).and_return(nil) }
|
43
24
|
|
44
|
-
|
25
|
+
it "raises a ResourceNotFound error" do
|
26
|
+
expect {
|
27
|
+
subject.regenerate_key(client_id)
|
28
|
+
}.to raise_error(Ridley::Errors::ResourceNotFound)
|
29
|
+
end
|
45
30
|
end
|
46
31
|
end
|
47
32
|
end
|
@@ -1,268 +1,94 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ridley::CookbookResource do
|
4
|
-
let(:
|
4
|
+
let(:client_name) { "reset" }
|
5
|
+
let(:client_key) { fixtures_path.join('reset.pem') }
|
6
|
+
let(:connection) { double('connection') }
|
7
|
+
subject { described_class.new(double('registry'), client_name, client_key) }
|
8
|
+
before { subject.stub(connection: connection) }
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
subject { described_class }
|
10
|
-
let(:server_url) { "https://api.opscode.com/organizations/vialstudios" }
|
11
|
-
let(:client_name) { "reset" }
|
12
|
-
let(:client_key) { fixtures_path.join("reset.pem") }
|
13
|
-
|
14
|
-
let(:client) do
|
15
|
-
Ridley.new(
|
16
|
-
server_url: server_url,
|
17
|
-
client_name: client_name,
|
18
|
-
client_key: client_key
|
19
|
-
)
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "::all" do
|
23
|
-
subject { described_class.all(client) }
|
24
|
-
|
25
|
-
before(:each) do
|
26
|
-
stub_request(:get, File.join(server_url, "cookbooks")).
|
27
|
-
to_return(status: 200, body: {
|
28
|
-
"ant" => {
|
29
|
-
"url" => "https://api.opscode.com/organizations/vialstudios/cookbooks/ant",
|
30
|
-
"versions" => [
|
31
|
-
{
|
32
|
-
"url" => "https://api.opscode.com/organizations/vialstudios/cookbooks/ant/0.10.1",
|
33
|
-
"version" => "0.10.1"
|
34
|
-
}
|
35
|
-
]
|
36
|
-
},
|
37
|
-
"apache2" => {
|
38
|
-
"url" => "https://api.opscode.com/organizations/vialstudios/cookbooks/apache2",
|
39
|
-
"versions" => [
|
40
|
-
{
|
41
|
-
"url" => "https://api.opscode.com/organizations/vialstudios/cookbooks/apache2/1.4.0",
|
42
|
-
"version" => "1.4.0"
|
43
|
-
}
|
44
|
-
]
|
45
|
-
}
|
46
|
-
}
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "returns a Hash" do
|
51
|
-
subject.should be_a(Hash)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "contains a key for each cookbook" do
|
55
|
-
subject.should include("ant")
|
56
|
-
subject.should include("apache2")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "contains an array of versions for each cookbook" do
|
60
|
-
subject["ant"].should be_a(Array)
|
61
|
-
subject["ant"].should have(1).item
|
62
|
-
subject["ant"].should include("0.10.1")
|
63
|
-
subject["apache2"].should be_a(Array)
|
64
|
-
subject["apache2"].should have(1).item
|
65
|
-
subject["apache2"].should include("1.4.0")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "::delete" do
|
70
|
-
let(:name) { "ant" }
|
71
|
-
let(:version) { "1.0.0" }
|
72
|
-
|
73
|
-
it "sends a DELETE to the cookbook version URL" do
|
74
|
-
stub_request(:delete, File.join(server_url, "cookbooks", name, version)).
|
75
|
-
to_return(status: 200, body: {})
|
76
|
-
|
77
|
-
described_class.delete(client, name, version)
|
78
|
-
end
|
79
|
-
|
80
|
-
context "when :purge is true" do
|
81
|
-
it "appends ?purge=true to the end of the URL" do
|
82
|
-
stub_request(:delete, File.join(server_url, "cookbooks", name, "#{version}?purge=true")).
|
83
|
-
to_return(status: 200, body: {})
|
84
|
-
|
85
|
-
described_class.delete(client, name, version, purge: true)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "::delete_all" do
|
91
|
-
let(:name) { "ant" }
|
92
|
-
let(:versions) { ["1.0.0", "1.2.0", "2.0.0"] }
|
93
|
-
let(:options) { Hash.new }
|
94
|
-
|
95
|
-
subject { described_class }
|
96
|
-
|
97
|
-
it "deletes each version of the cookbook" do
|
98
|
-
subject.should_receive(:versions).with(client, name).and_return(versions)
|
10
|
+
describe "#download" do
|
11
|
+
pending
|
12
|
+
end
|
99
13
|
|
100
|
-
|
101
|
-
|
102
|
-
end
|
14
|
+
describe "#latest_version" do
|
15
|
+
let(:name) { "ant" }
|
103
16
|
|
104
|
-
|
105
|
-
|
17
|
+
before(:each) do
|
18
|
+
subject.should_receive(:versions).with(name).and_return(versions)
|
106
19
|
end
|
107
20
|
|
108
|
-
|
109
|
-
let(:
|
110
|
-
subject { described_class }
|
111
|
-
|
112
|
-
before(:each) do
|
113
|
-
subject.should_receive(:versions).with(client, name).and_return(versions)
|
114
|
-
end
|
115
|
-
|
116
|
-
context "when the cookbook has no versions" do
|
117
|
-
let(:versions) { Array.new }
|
118
|
-
|
119
|
-
it "returns nil" do
|
120
|
-
subject.latest_version(client, name).should be_nil
|
121
|
-
end
|
122
|
-
end
|
21
|
+
context "when the cookbook has no versions" do
|
22
|
+
let(:versions) { Array.new }
|
123
23
|
|
124
|
-
|
125
|
-
|
126
|
-
[ "1.0.0", "1.2.0", "3.0.0", "1.4.1" ]
|
127
|
-
end
|
128
|
-
|
129
|
-
it "returns nil" do
|
130
|
-
subject.latest_version(client, name).should eql("3.0.0")
|
131
|
-
end
|
24
|
+
it "returns nil" do
|
25
|
+
subject.latest_version(name).should be_nil
|
132
26
|
end
|
133
27
|
end
|
134
28
|
|
135
|
-
|
136
|
-
let(:
|
137
|
-
|
138
|
-
|
139
|
-
before(:each) do
|
140
|
-
stub_request(:get, File.join(server_url, "cookbooks", cookbook)).
|
141
|
-
to_return(status: 200, body: {
|
142
|
-
cookbook => {
|
143
|
-
"versions" => [
|
144
|
-
{
|
145
|
-
"url" => "https://api.opscode.com/organizations/ridley/cookbooks/artifact/1.0.0",
|
146
|
-
"version" => "1.0.0"
|
147
|
-
},
|
148
|
-
{
|
149
|
-
"url" => "https://api.opscode.com/organizations/ridley/cookbooks/artifact/1.1.0",
|
150
|
-
"version" => "1.1.0"
|
151
|
-
},
|
152
|
-
{
|
153
|
-
"url" => "https://api.opscode.com/organizations/ridley/cookbooks/artifact/1.2.0",
|
154
|
-
"version" => "1.2.0"
|
155
|
-
}
|
156
|
-
],
|
157
|
-
"url" => "https://api.opscode.com/organizations/ridley/cookbooks/artifact"}
|
158
|
-
}
|
159
|
-
)
|
29
|
+
context "when the cookbook has versions" do
|
30
|
+
let(:versions) do
|
31
|
+
[ "1.0.0", "1.2.0", "3.0.0", "1.4.1" ]
|
160
32
|
end
|
161
33
|
|
162
|
-
it "returns
|
163
|
-
subject.should
|
164
|
-
end
|
165
|
-
|
166
|
-
it "contains a version string for each cookbook version available" do
|
167
|
-
subject.should have(3).versions
|
168
|
-
subject.should include("1.0.0")
|
169
|
-
subject.should include("1.1.0")
|
170
|
-
subject.should include("1.2.0")
|
34
|
+
it "returns nil" do
|
35
|
+
subject.latest_version(name).should eql("3.0.0")
|
171
36
|
end
|
172
37
|
end
|
173
|
-
|
174
|
-
describe "::upload" do
|
175
|
-
pending
|
176
|
-
end
|
177
|
-
|
178
|
-
describe "::update" do
|
179
|
-
pending
|
180
|
-
end
|
181
38
|
end
|
182
39
|
|
183
|
-
describe "#
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
40
|
+
describe "#versions" do
|
41
|
+
let(:cookbook) { "artifact" }
|
42
|
+
let(:versions_path) { "#{described_class.resource_path}/#{cookbook}" }
|
43
|
+
let(:response) do
|
44
|
+
double(body: {
|
45
|
+
cookbook => {
|
46
|
+
"versions" => [
|
190
47
|
{
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
url
|
196
|
-
|
197
|
-
|
198
|
-
definitions: [],
|
199
|
-
libraries: [],
|
200
|
-
attributes: [],
|
201
|
-
files: [
|
48
|
+
"url" => "https://api.opscode.com/organizations/ridley/cookbooks/artifact/1.0.0",
|
49
|
+
"version" => "1.0.0"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"url" => "https://api.opscode.com/organizations/ridley/cookbooks/artifact/1.1.0",
|
53
|
+
"version" => "1.1.0"
|
54
|
+
},
|
202
55
|
{
|
203
|
-
|
204
|
-
|
205
|
-
path: "files/default/plugins/README",
|
206
|
-
specificity: "plugins",
|
207
|
-
url: "https://chef.lax1.riotgames.com/organizations/reset/cookbooks/ohai/1.0.2/files/85bc3bb921efade3f2566a668ab4b639"
|
56
|
+
"url" => "https://api.opscode.com/organizations/ridley/cookbooks/artifact/1.2.0",
|
57
|
+
"version" => "1.2.0"
|
208
58
|
}
|
209
59
|
],
|
210
|
-
|
211
|
-
root_files: []
|
60
|
+
"url" => "https://api.opscode.com/organizations/ridley/cookbooks/artifact"
|
212
61
|
}
|
213
|
-
|
214
|
-
|
215
|
-
subject.should_receive(:download_file).with(:recipes, "recipes/default.rb", anything)
|
216
|
-
subject.should_receive(:download_file).with(:files, "files/default/plugins/README", anything)
|
217
|
-
|
218
|
-
subject.download
|
62
|
+
})
|
219
63
|
end
|
220
|
-
end
|
221
|
-
|
222
|
-
describe "#download_file" do
|
223
|
-
let(:destination) { tmp_path.join('fake.file').to_s }
|
224
64
|
|
225
65
|
before(:each) do
|
226
|
-
|
66
|
+
connection.should_receive(:get).with(versions_path).and_return(response)
|
227
67
|
end
|
228
68
|
|
229
|
-
it "
|
230
|
-
|
231
|
-
|
232
|
-
subject.download_file(:root_file, "metadata.rb", destination)
|
69
|
+
it "returns an array" do
|
70
|
+
subject.versions(cookbook).should be_a(Array)
|
233
71
|
end
|
234
72
|
|
235
|
-
|
236
|
-
|
237
|
-
expect {
|
238
|
-
subject.download_file(:not_existant, "default.rb", destination)
|
239
|
-
}.to raise_error(Ridley::Errors::UnknownCookbookFileType)
|
240
|
-
end
|
241
|
-
end
|
73
|
+
it "contains a version string for each cookbook version available" do
|
74
|
+
result = subject.versions(cookbook)
|
242
75
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
it "returns nil" do
|
249
|
-
subject.download_file(:root_file, "metadata.rb", destination).should be_nil
|
250
|
-
end
|
76
|
+
result.should have(3).versions
|
77
|
+
result.should include("1.0.0")
|
78
|
+
result.should include("1.1.0")
|
79
|
+
result.should include("1.2.0")
|
251
80
|
end
|
252
81
|
end
|
253
82
|
|
254
|
-
describe "#
|
255
|
-
|
256
|
-
|
257
|
-
end
|
83
|
+
describe "#satisfy" do
|
84
|
+
pending
|
85
|
+
end
|
258
86
|
|
259
|
-
|
260
|
-
|
261
|
-
|
87
|
+
describe "#upload" do
|
88
|
+
pending
|
89
|
+
end
|
262
90
|
|
263
|
-
|
264
|
-
|
265
|
-
subject.manifest.values.should each be_empty
|
266
|
-
end
|
91
|
+
describe "#update" do
|
92
|
+
pending
|
267
93
|
end
|
268
94
|
end
|