ridley 0.11.2 → 0.12.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/Gemfile +0 -1
- data/README.md +3 -23
- data/lib/ridley/bootstrap_bindings/windows_template_binding.rb +1 -1
- data/lib/ridley/client.rb +4 -24
- data/lib/ridley/host_connector.rb +3 -3
- data/lib/ridley/resources/environment_resource.rb +19 -0
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +2 -2
- data/spec/acceptance/environment_resource_spec.rb +9 -18
- data/spec/acceptance/node_resource_spec.rb +27 -47
- data/spec/acceptance/role_resource_spec.rb +24 -43
- data/spec/unit/ridley/client_spec.rb +23 -26
- data/spec/unit/ridley/host_connector_spec.rb +6 -6
- data/spec/unit/ridley/resources/environment_resource_spec.rb +54 -1
- metadata +9 -12
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -40,30 +40,10 @@ Ridley exposes a number of functions that return resources which you can use to
|
|
40
40
|
|
41
41
|
For more information scroll down to the Manipulating Chef Resources section of this README.
|
42
42
|
|
43
|
-
|
43
|
+
If you don't want to instantiate and manage a connection object you can use `Ridley.open` to open a connection, do some work, and it will be closed for you after the block executes.
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
ridley = Ridley.new(...)
|
48
|
-
ridley.sync do
|
49
|
-
role.all
|
50
|
-
role.find("reset")
|
51
|
-
role.create(name: "ridley-test")
|
52
|
-
role.delete("reset")
|
53
|
-
end
|
54
|
-
|
55
|
-
The `sync` function on the connection object takes a block with no arguments and allows you to access the DSL within the block. You can address any one of the resources within the sync block:
|
56
|
-
|
57
|
-
ridley.sync do
|
58
|
-
environment.all
|
59
|
-
node.all
|
60
|
-
...
|
61
|
-
end
|
62
|
-
|
63
|
-
For one-liner requests you can create a new instance of Ridley and dispose of it with `Ridley.open`
|
64
|
-
|
65
|
-
Ridley.open(server_url: "https://api.opscode.com", ...) do
|
66
|
-
role.all
|
45
|
+
Ridley.open(server_url: "https://api.opscode.com", ...) do |r|
|
46
|
+
r.node.all
|
67
47
|
end
|
68
48
|
|
69
49
|
## Manipulating Chef Resources
|
@@ -79,7 +79,7 @@ CONFIG
|
|
79
79
|
end
|
80
80
|
|
81
81
|
if encrypted_data_bag_secret.present?
|
82
|
-
body << %Q{encrypted_data_bag_secret
|
82
|
+
body << %Q{encrypted_data_bag_secret '#{bootstrap_directory}\\encrypted_data_bag_secret'\n}
|
83
83
|
end
|
84
84
|
|
85
85
|
escape_and_echo(body)
|
data/lib/ridley/client.rb
CHANGED
@@ -54,8 +54,10 @@ module Ridley
|
|
54
54
|
|
55
55
|
class << self
|
56
56
|
def open(options = {}, &block)
|
57
|
-
|
58
|
-
|
57
|
+
client = new(options)
|
58
|
+
yield client
|
59
|
+
ensure
|
60
|
+
client.terminate if client && client.alive?
|
59
61
|
end
|
60
62
|
|
61
63
|
# @raise [ArgumentError]
|
@@ -266,32 +268,10 @@ module Ridley
|
|
266
268
|
self.url_prefix.to_s
|
267
269
|
end
|
268
270
|
|
269
|
-
def evaluate(&block)
|
270
|
-
unless block_given?
|
271
|
-
raise LocalJumpError, "no block given (yield)"
|
272
|
-
end
|
273
|
-
|
274
|
-
@self_before_instance_eval = eval("self", block.binding)
|
275
|
-
instance_eval(&block)
|
276
|
-
end
|
277
|
-
alias_method :sync, :evaluate
|
278
|
-
|
279
271
|
private
|
280
272
|
|
281
273
|
def connection
|
282
274
|
@connection_registry[:connection_pool]
|
283
275
|
end
|
284
|
-
|
285
|
-
def method_missing(method, *args, &block)
|
286
|
-
if block_given?
|
287
|
-
@self_before_instance_eval ||= eval("self", block.binding)
|
288
|
-
end
|
289
|
-
|
290
|
-
if @self_before_instance_eval.nil?
|
291
|
-
super
|
292
|
-
end
|
293
|
-
|
294
|
-
@self_before_instance_eval.send(method, *args, &block)
|
295
|
-
end
|
296
276
|
end
|
297
277
|
end
|
@@ -53,10 +53,10 @@ module Ridley
|
|
53
53
|
ssh_port, winrm_port = parse_port_options(options)
|
54
54
|
timeout = options[:ssh] && options[:ssh][:timeout]
|
55
55
|
|
56
|
-
if connector_port_open?(host,
|
57
|
-
host_connector = Ridley::HostConnector::WinRM
|
58
|
-
elsif connector_port_open?(host, ssh_port, timeout)
|
56
|
+
if connector_port_open?(host, ssh_port, timeout)
|
59
57
|
host_connector = Ridley::HostConnector::SSH
|
58
|
+
elsif connector_port_open?(host, winrm_port)
|
59
|
+
host_connector = Ridley::HostConnector::WinRM
|
60
60
|
else
|
61
61
|
raise Ridley::Errors::HostConnectionError, "No available connection method available on #{host}."
|
62
62
|
end
|
@@ -4,6 +4,25 @@ module Ridley
|
|
4
4
|
set_resource_path "environments"
|
5
5
|
represented_by Ridley::EnvironmentObject
|
6
6
|
|
7
|
+
# Used to return a hash of the cookbooks and cookbook versions (including all dependencies)
|
8
|
+
# that are required by the run_list array.
|
9
|
+
#
|
10
|
+
# @param [String] environment
|
11
|
+
# name of the environment to run against
|
12
|
+
# @param [Array] run_list
|
13
|
+
# an array of cookbooks to satisfy
|
14
|
+
#
|
15
|
+
# @raise [Errors::ResourceNotFound] if the given environment is not found
|
16
|
+
#
|
17
|
+
# @return [Hash]
|
18
|
+
def cookbook_versions(environment, run_list = [])
|
19
|
+
run_list = Array(run_list).flatten
|
20
|
+
chef_id = environment.respond_to?(:chef_id) ? environment.chef_id : environment
|
21
|
+
request(:post, "#{self.class.resource_path}/#{chef_id}/cookbook_versions", MultiJson.encode(run_list: run_list))
|
22
|
+
rescue Errors::HTTPNotFound => ex
|
23
|
+
abort Errors::ResourceNotFound.new(ex)
|
24
|
+
end
|
25
|
+
|
7
26
|
# Delete all of the environments on the client. The '_default' environment
|
8
27
|
# will never be deleted.
|
9
28
|
#
|
data/lib/ridley/version.rb
CHANGED
data/ridley.gemspec
CHANGED
@@ -27,8 +27,8 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency 'addressable'
|
28
28
|
s.add_runtime_dependency 'faraday', '>= 0.8.4'
|
29
29
|
s.add_runtime_dependency 'activesupport', '>= 3.2.0'
|
30
|
-
s.add_runtime_dependency 'solve', '>= 0.4.
|
31
|
-
s.add_runtime_dependency 'celluloid', '~> 0.
|
30
|
+
s.add_runtime_dependency 'solve', '>= 0.4.4'
|
31
|
+
s.add_runtime_dependency 'celluloid', '~> 0.14.0'
|
32
32
|
s.add_runtime_dependency 'net-ssh'
|
33
33
|
s.add_runtime_dependency 'erubis'
|
34
34
|
s.add_runtime_dependency 'net-http-persistent', '>= 2.8'
|
@@ -90,12 +90,9 @@ describe "Environment API operations", type: "acceptance" do
|
|
90
90
|
}
|
91
91
|
}
|
92
92
|
|
93
|
-
connection.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
obj.default_attributes.should eql(default_attributes)
|
98
|
-
end
|
93
|
+
connection.environment.update(target)
|
94
|
+
obj = connection.environment.find(target)
|
95
|
+
obj.default_attributes.should eql(default_attributes)
|
99
96
|
end
|
100
97
|
|
101
98
|
it "saves a new set of 'override_attributes'" do
|
@@ -106,12 +103,9 @@ describe "Environment API operations", type: "acceptance" do
|
|
106
103
|
}
|
107
104
|
}
|
108
105
|
|
109
|
-
connection.
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
obj.override_attributes.should eql(override_attributes)
|
114
|
-
end
|
106
|
+
connection.environment.update(target)
|
107
|
+
obj = connection.environment.find(target)
|
108
|
+
obj.override_attributes.should eql(override_attributes)
|
115
109
|
end
|
116
110
|
|
117
111
|
it "saves a new set of 'cookbook_versions'" do
|
@@ -120,12 +114,9 @@ describe "Environment API operations", type: "acceptance" do
|
|
120
114
|
"tomcat" => "1.3.0"
|
121
115
|
}
|
122
116
|
|
123
|
-
connection.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
obj.cookbook_versions.should eql(cookbook_versions)
|
128
|
-
end
|
117
|
+
connection.environment.update(target)
|
118
|
+
obj = connection.environment.find(target)
|
119
|
+
obj.cookbook_versions.should eql(cookbook_versions)
|
129
120
|
end
|
130
121
|
end
|
131
122
|
end
|
@@ -23,11 +23,9 @@ describe "Node API operations", type: "acceptance" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "adds a new node to the server" do
|
26
|
-
connection.
|
27
|
-
node.create(name: node_name)
|
26
|
+
connection.node.create(name: node_name)
|
28
27
|
|
29
|
-
|
30
|
-
end
|
28
|
+
connection.node.all.should have(1).node
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
@@ -40,11 +38,9 @@ describe "Node API operations", type: "acceptance" do
|
|
40
38
|
end
|
41
39
|
|
42
40
|
it "removes the node from the server" do
|
43
|
-
connection.
|
44
|
-
node.delete(node_name)
|
41
|
+
connection.node.delete(node_name)
|
45
42
|
|
46
|
-
|
47
|
-
end
|
43
|
+
connection.node.find(node_name).should be_nil
|
48
44
|
end
|
49
45
|
end
|
50
46
|
|
@@ -55,11 +51,9 @@ describe "Node API operations", type: "acceptance" do
|
|
55
51
|
end
|
56
52
|
|
57
53
|
it "deletes all nodes from the remote server" do
|
58
|
-
connection.
|
59
|
-
node.delete_all
|
54
|
+
connection.node.delete_all
|
60
55
|
|
61
|
-
|
62
|
-
end
|
56
|
+
connection.node.all.should have(0).nodes
|
63
57
|
end
|
64
58
|
end
|
65
59
|
|
@@ -70,12 +64,10 @@ describe "Node API operations", type: "acceptance" do
|
|
70
64
|
end
|
71
65
|
|
72
66
|
it "returns an array of Ridley::NodeObject" do
|
73
|
-
connection.
|
74
|
-
obj = node.all
|
67
|
+
obj = connection.node.all
|
75
68
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
69
|
+
obj.should each be_a(Ridley::NodeObject)
|
70
|
+
obj.should have(2).nodes
|
79
71
|
end
|
80
72
|
end
|
81
73
|
|
@@ -96,12 +88,10 @@ describe "Node API operations", type: "acceptance" do
|
|
96
88
|
}
|
97
89
|
}
|
98
90
|
|
99
|
-
connection.
|
100
|
-
|
101
|
-
obj = node.find(target)
|
91
|
+
connection.node.update(target)
|
92
|
+
obj = connection.node.find(target)
|
102
93
|
|
103
|
-
|
104
|
-
end
|
94
|
+
obj.normal.should eql(normal)
|
105
95
|
end
|
106
96
|
|
107
97
|
it "saves a new set of 'default' attributes" do
|
@@ -112,12 +102,10 @@ describe "Node API operations", type: "acceptance" do
|
|
112
102
|
}
|
113
103
|
}
|
114
104
|
|
115
|
-
connection.
|
116
|
-
|
117
|
-
obj = node.find(target)
|
105
|
+
connection.node.update(target)
|
106
|
+
obj = connection.node.find(target)
|
118
107
|
|
119
|
-
|
120
|
-
end
|
108
|
+
obj.default.should eql(defaults)
|
121
109
|
end
|
122
110
|
|
123
111
|
it "saves a new set of 'automatic' attributes" do
|
@@ -128,12 +116,10 @@ describe "Node API operations", type: "acceptance" do
|
|
128
116
|
}
|
129
117
|
}
|
130
118
|
|
131
|
-
connection.
|
132
|
-
|
133
|
-
obj = node.find(target)
|
119
|
+
connection.node.update(target)
|
120
|
+
obj = connection.node.find(target)
|
134
121
|
|
135
|
-
|
136
|
-
end
|
122
|
+
obj.automatic.should eql(automatics)
|
137
123
|
end
|
138
124
|
|
139
125
|
it "saves a new set of 'override' attributes" do
|
@@ -144,34 +130,28 @@ describe "Node API operations", type: "acceptance" do
|
|
144
130
|
}
|
145
131
|
}
|
146
132
|
|
147
|
-
connection.
|
148
|
-
|
149
|
-
obj = node.find(target)
|
133
|
+
connection.node.update(target)
|
134
|
+
obj = connection.node.find(target)
|
150
135
|
|
151
|
-
|
152
|
-
end
|
136
|
+
obj.override.should eql(overrides)
|
153
137
|
end
|
154
138
|
|
155
139
|
it "places a node in a new 'chef_environment'" do
|
156
140
|
target.chef_environment = environment = "ridley"
|
157
141
|
|
158
|
-
connection.
|
159
|
-
|
160
|
-
obj = node.find(target)
|
142
|
+
connection.node.update(target)
|
143
|
+
obj = connection.node.find(target)
|
161
144
|
|
162
|
-
|
163
|
-
end
|
145
|
+
obj.chef_environment.should eql(environment)
|
164
146
|
end
|
165
147
|
|
166
148
|
it "saves a new 'run_list' for the node" do
|
167
149
|
target.run_list = run_list = ["recipe[one]", "recipe[two]"]
|
168
150
|
|
169
|
-
connection.
|
170
|
-
|
171
|
-
obj = node.find(target)
|
151
|
+
connection.node.update(target)
|
152
|
+
obj = connection.node.find(target)
|
172
153
|
|
173
|
-
|
174
|
-
end
|
154
|
+
obj.run_list.should eql(run_list)
|
175
155
|
end
|
176
156
|
end
|
177
157
|
end
|
@@ -23,11 +23,8 @@ describe "Role API operations", type: "acceptance" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "adds a new role to the server" do
|
26
|
-
connection.
|
27
|
-
|
28
|
-
|
29
|
-
role.all.should have(1).role
|
30
|
-
end
|
26
|
+
connection.role.create(name: role_name)
|
27
|
+
connection.role.all.should have(1).role
|
31
28
|
end
|
32
29
|
end
|
33
30
|
|
@@ -40,11 +37,9 @@ describe "Role API operations", type: "acceptance" do
|
|
40
37
|
end
|
41
38
|
|
42
39
|
it "removes the role from the server" do
|
43
|
-
connection.
|
44
|
-
role.delete(role_name)
|
40
|
+
connection.role.delete(role_name)
|
45
41
|
|
46
|
-
|
47
|
-
end
|
42
|
+
connection.role.find(role_name).should be_nil
|
48
43
|
end
|
49
44
|
end
|
50
45
|
|
@@ -55,11 +50,9 @@ describe "Role API operations", type: "acceptance" do
|
|
55
50
|
end
|
56
51
|
|
57
52
|
it "deletes all nodes from the remote server" do
|
58
|
-
connection.
|
59
|
-
role.delete_all
|
53
|
+
connection.role.delete_all
|
60
54
|
|
61
|
-
|
62
|
-
end
|
55
|
+
connection.role.all.should have(0).roles
|
63
56
|
end
|
64
57
|
end
|
65
58
|
|
@@ -70,12 +63,10 @@ describe "Role API operations", type: "acceptance" do
|
|
70
63
|
end
|
71
64
|
|
72
65
|
it "should return an array of Ridley::RoleObject" do
|
73
|
-
connection.
|
74
|
-
obj = role.all
|
66
|
+
obj = connection.role.all
|
75
67
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
68
|
+
obj.should have(2).roles
|
69
|
+
obj.should each be_a(Ridley::RoleObject)
|
79
70
|
end
|
80
71
|
end
|
81
72
|
|
@@ -91,12 +82,10 @@ describe "Role API operations", type: "acceptance" do
|
|
91
82
|
it "saves a new run_list" do
|
92
83
|
target.run_list = run_list = ["recipe[one]", "recipe[two]"]
|
93
84
|
|
94
|
-
connection.
|
95
|
-
|
96
|
-
obj = role.find(target)
|
85
|
+
connection.role.update(target)
|
86
|
+
obj = connection.role.find(target)
|
97
87
|
|
98
|
-
|
99
|
-
end
|
88
|
+
obj.run_list.should eql(run_list)
|
100
89
|
end
|
101
90
|
|
102
91
|
it "saves a new env_run_lists" do
|
@@ -105,23 +94,19 @@ describe "Role API operations", type: "acceptance" do
|
|
105
94
|
"development" => ["recipe[two]"]
|
106
95
|
}
|
107
96
|
|
108
|
-
connection.
|
109
|
-
|
110
|
-
obj = role.find(target)
|
97
|
+
connection.role.update(target)
|
98
|
+
obj = connection.role.find(target)
|
111
99
|
|
112
|
-
|
113
|
-
end
|
100
|
+
obj.env_run_lists.should eql(env_run_lists)
|
114
101
|
end
|
115
102
|
|
116
103
|
it "saves a new description" do
|
117
104
|
target.description = description = "a new description!"
|
118
105
|
|
119
|
-
connection.
|
120
|
-
|
121
|
-
obj = role.find(target)
|
106
|
+
connection.role.update(target)
|
107
|
+
obj = connection.role.find(target)
|
122
108
|
|
123
|
-
|
124
|
-
end
|
109
|
+
obj.description.should eql(description)
|
125
110
|
end
|
126
111
|
|
127
112
|
it "saves a new default_attributes" do
|
@@ -132,12 +117,10 @@ describe "Role API operations", type: "acceptance" do
|
|
132
117
|
}
|
133
118
|
}
|
134
119
|
|
135
|
-
connection.
|
136
|
-
|
137
|
-
obj = role.find(target)
|
120
|
+
connection.role.update(target)
|
121
|
+
obj = connection.role.find(target)
|
138
122
|
|
139
|
-
|
140
|
-
end
|
123
|
+
obj.default_attributes.should eql(defaults)
|
141
124
|
end
|
142
125
|
|
143
126
|
it "saves a new override_attributes" do
|
@@ -148,12 +131,10 @@ describe "Role API operations", type: "acceptance" do
|
|
148
131
|
}
|
149
132
|
}
|
150
133
|
|
151
|
-
connection.
|
152
|
-
|
153
|
-
obj = role.find(target)
|
134
|
+
connection.role.update(target)
|
135
|
+
obj = connection.role.find(target)
|
154
136
|
|
155
|
-
|
156
|
-
end
|
137
|
+
obj.override_attributes.should eql(overrides)
|
157
138
|
end
|
158
139
|
end
|
159
140
|
end
|
@@ -115,56 +115,53 @@ describe Ridley::Client do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
describe "::open" do
|
118
|
-
it "
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
it "instantiates a new connection, yields to it, and terminates it" do
|
119
|
+
new_instance = double(alive?: true)
|
120
|
+
described_class.should_receive(:new).and_return(new_instance)
|
121
|
+
new_instance.should_receive(:hello)
|
122
|
+
new_instance.should_receive(:terminate)
|
123
|
+
|
124
|
+
described_class.open do |f|
|
125
|
+
f.hello
|
126
|
+
end
|
122
127
|
end
|
123
128
|
end
|
124
129
|
end
|
125
130
|
|
126
131
|
let(:instance) { described_class.new(config) }
|
127
132
|
|
128
|
-
|
129
|
-
subject { instance.node }
|
130
|
-
|
131
|
-
it { should be_a(Ridley::NodeResource) }
|
133
|
+
subject { instance }
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
end
|
135
|
+
its(:client) { should be_a(Ridley::ClientResource) }
|
136
|
+
its(:cookbook) { should be_a(Ridley::CookbookResource) }
|
137
|
+
its(:data_bag) { should be_a(Ridley::DataBagResource) }
|
138
|
+
its(:environment) { should be_a(Ridley::EnvironmentResource) }
|
139
|
+
its(:node) { should be_a(Ridley::NodeResource) }
|
140
|
+
its(:role) { should be_a(Ridley::RoleResource) }
|
141
|
+
its(:sandbox) { should be_a(Ridley::SandboxResource) }
|
141
142
|
|
142
143
|
describe "#encrypted_data_bag_secret" do
|
143
|
-
subject { instance }
|
144
|
+
subject { instance.encrypted_data_bag_secret }
|
144
145
|
|
145
|
-
it
|
146
|
-
subject.encrypted_data_bag_secret.should be_a(String)
|
147
|
-
end
|
146
|
+
it { should be_a(String) }
|
148
147
|
|
149
148
|
context "when a encrypted_data_bag_secret_path is not provided" do
|
150
149
|
before(:each) do
|
151
|
-
|
150
|
+
instance.stub(encrypted_data_bag_secret_path: nil)
|
152
151
|
end
|
153
152
|
|
154
153
|
it "returns nil" do
|
155
|
-
subject.
|
154
|
+
expect(subject).to be_nil
|
156
155
|
end
|
157
156
|
end
|
158
157
|
|
159
158
|
context "when the file is not found at the given encrypted_data_bag_secret_path" do
|
160
159
|
before(:each) do
|
161
|
-
|
160
|
+
instance.stub(encrypted_data_bag_secret_path: fixtures_path.join("not.txt").to_s)
|
162
161
|
end
|
163
162
|
|
164
163
|
it "raises an EncryptedDataBagSecretNotFound erorr" do
|
165
|
-
|
166
|
-
subject.encrypted_data_bag_secret
|
167
|
-
}.should raise_error(Ridley::Errors::EncryptedDataBagSecretNotFound)
|
164
|
+
expect { subject }.to raise_error(Ridley::Errors::EncryptedDataBagSecretNotFound)
|
168
165
|
end
|
169
166
|
end
|
170
167
|
end
|
@@ -96,15 +96,15 @@ describe Ridley::HostConnector do
|
|
96
96
|
|
97
97
|
context "when an SSH port is open" do
|
98
98
|
it "returns Ridley::HostConnector::SSH" do
|
99
|
-
subject.stub(:connector_port_open?).and_return(
|
100
|
-
|
99
|
+
subject.stub(:connector_port_open?).and_return(true)
|
100
|
+
subject.best_connector_for(host).should eq(Ridley::HostConnector::SSH)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
context "when an SSH port isnt open and a WinRM port is open" do
|
105
105
|
it "retrns Ridley::HostConnector::WinRM" do
|
106
|
-
subject.stub(:connector_port_open?).and_return(
|
107
|
-
|
106
|
+
subject.stub(:connector_port_open?).and_return(false, true)
|
107
|
+
subject.best_connector_for(host).should eq(Ridley::HostConnector::WinRM)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -119,9 +119,9 @@ describe Ridley::HostConnector do
|
|
119
119
|
|
120
120
|
context "when a block is provided" do
|
121
121
|
it "yields the best HostConnector to the block" do
|
122
|
-
subject.stub(:connector_port_open?).and_return(
|
122
|
+
subject.stub(:connector_port_open?).and_return(true)
|
123
123
|
subject.best_connector_for(host) do |yielded|
|
124
|
-
|
124
|
+
yielded.should eq(Ridley::HostConnector::SSH)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
@@ -1,7 +1,60 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ridley::EnvironmentResource do
|
4
|
-
|
4
|
+
let(:server_url) { Ridley::RSpec::ChefServer.server_url }
|
5
|
+
let(:client_name) { "reset" }
|
6
|
+
let(:client_key) { fixtures_path.join('reset.pem').to_s }
|
7
|
+
let(:connection) { Ridley::Connection.new(server_url, client_name, client_key) }
|
8
|
+
|
9
|
+
let(:resource) do
|
10
|
+
resource = described_class.new(double('registry'))
|
11
|
+
resource.stub(connection: connection)
|
12
|
+
resource
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { resource }
|
16
|
+
|
17
|
+
describe "#cookbook_versions" do
|
18
|
+
let(:name) { "rspec-test" }
|
19
|
+
let(:run_list) { ["hello", "there"] }
|
20
|
+
|
21
|
+
subject { resource.cookbook_versions(name, run_list) }
|
22
|
+
|
23
|
+
context "when the chef server has the given cookbooks" do
|
24
|
+
before do
|
25
|
+
chef_environment("rspec-test")
|
26
|
+
chef_cookbook("hello", "1.2.3")
|
27
|
+
chef_cookbook("there", "1.0.0")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns a Hash" do
|
31
|
+
should be_a(Hash)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "contains a key for each cookbook" do
|
35
|
+
subject.keys.should have(2).items
|
36
|
+
subject.should have_key("hello")
|
37
|
+
subject.should have_key("there")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when the chef server does not have the environment" do
|
42
|
+
before do
|
43
|
+
chef_cookbook("hello", "1.2.3")
|
44
|
+
chef_cookbook("there", "1.0.0")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "raises a ResourceNotFound error" do
|
48
|
+
expect { subject }.to raise_error(Ridley::Errors::ResourceNotFound)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when the chef server does not have one or more of the cookbooks" do
|
53
|
+
it "raises a precondition failed error" do
|
54
|
+
expect { subject }.to raise_error(Ridley::Errors::HTTPPreconditionFailed)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
5
58
|
|
6
59
|
describe "#delete_all" do
|
7
60
|
let(:default_env) { double(name: "_default") }
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridley
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.12.0.rc1
|
5
|
+
prerelease: 7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jamie Winsor
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -178,7 +178,7 @@ dependencies:
|
|
178
178
|
requirements:
|
179
179
|
- - ! '>='
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version: 0.4.
|
181
|
+
version: 0.4.4
|
182
182
|
type: :runtime
|
183
183
|
prerelease: false
|
184
184
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -186,7 +186,7 @@ dependencies:
|
|
186
186
|
requirements:
|
187
187
|
- - ! '>='
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version: 0.4.
|
189
|
+
version: 0.4.4
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
191
|
name: celluloid
|
192
192
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,7 +194,7 @@ dependencies:
|
|
194
194
|
requirements:
|
195
195
|
- - ~>
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
version: 0.
|
197
|
+
version: 0.14.0
|
198
198
|
type: :runtime
|
199
199
|
prerelease: false
|
200
200
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -202,7 +202,7 @@ dependencies:
|
|
202
202
|
requirements:
|
203
203
|
- - ~>
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version: 0.
|
205
|
+
version: 0.14.0
|
206
206
|
- !ruby/object:Gem::Dependency
|
207
207
|
name: net-ssh
|
208
208
|
requirement: !ruby/object:Gem::Requirement
|
@@ -451,12 +451,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
451
451
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
452
452
|
none: false
|
453
453
|
requirements:
|
454
|
-
- - ! '
|
454
|
+
- - ! '>'
|
455
455
|
- !ruby/object:Gem::Version
|
456
|
-
version:
|
457
|
-
segments:
|
458
|
-
- 0
|
459
|
-
hash: 4471568292874425542
|
456
|
+
version: 1.3.1
|
460
457
|
requirements: []
|
461
458
|
rubyforge_project:
|
462
459
|
rubygems_version: 1.8.23
|