spice 0.2.0 → 0.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.
- data/.DS_Store +0 -0
- data/.document +0 -0
- data/.gitignore +5 -0
- data/.rspec +1 -1
- data/CHANGELOG.md +16 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +2 -5
- data/LICENSE.txt +0 -0
- data/Notes.md +0 -0
- data/README.md +2 -2
- data/Rakefile +0 -0
- data/TODO.md +2 -2
- data/features/spice.feature +0 -0
- data/features/step_definitions/spice_steps.rb +0 -0
- data/features/support/env.rb +0 -0
- data/file.txt +0 -0
- data/lib/spice/authentication.rb +0 -0
- data/lib/spice/chef.rb +0 -15
- data/lib/spice/client.rb +3 -3
- data/lib/spice/connection.rb +34 -26
- data/lib/spice/cookbook.rb +0 -0
- data/lib/spice/data_bag.rb +103 -4
- data/{spec/support/authentication.rb → lib/spice/mock.rb} +17 -14
- data/lib/spice/node.rb +0 -0
- data/lib/spice/role.rb +0 -0
- data/lib/spice/version.rb +1 -1
- data/lib/spice.rb +8 -0
- data/pkg/spice-0.0.1.alpha.1.gem +0 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/spice/authentication_spec.rb +0 -0
- data/spec/spice/chef_spec.rb +1 -1
- data/spec/spice/client_spec.rb +4 -4
- data/spec/spice/connection_spec.rb +0 -0
- data/spec/spice/cookbook_spec.rb +91 -14
- data/spec/spice/data_bag_spec.rb +151 -8
- data/spec/spice/node_spec.rb +0 -29
- data/spec/spice/role_spec.rb +1 -29
- data/spec/spice_spec.rb +0 -0
- data/spec/support/client_requests.rb +97 -0
- data/spec/support/cookbook_requests.rb +172 -0
- data/spec/support/data_bag_item_requests.rb +138 -0
- data/spec/support/data_bag_requests.rb +95 -0
- data/spec/support/respond_with_matcher.rb +53 -0
- data/spec/support/vcr.rb +0 -0
- data/spice.gemspec +0 -0
- metadata +16 -5
@@ -0,0 +1,95 @@
|
|
1
|
+
def stub_data_bag_list
|
2
|
+
stub_request(:get, "http://localhost:4000/data").
|
3
|
+
to_return(
|
4
|
+
:status => 200,
|
5
|
+
:body => data_bag_list_response
|
6
|
+
)
|
7
|
+
end
|
8
|
+
|
9
|
+
def stub_data_bag_show(status=200)
|
10
|
+
case status
|
11
|
+
when 200
|
12
|
+
stub_request(:get, "http://localhost:4000/data/users").
|
13
|
+
to_return(
|
14
|
+
:status => status,
|
15
|
+
:body => data_bag_show_response
|
16
|
+
)
|
17
|
+
when 404
|
18
|
+
stub_request(:get, "http://localhost:4000/data/users").
|
19
|
+
to_return(
|
20
|
+
:status => status,
|
21
|
+
:body => data_bag_not_found
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def stub_data_bag_create(status=201)
|
27
|
+
case status
|
28
|
+
when 201
|
29
|
+
stub_request(:post, "http://localhost:4000/data").
|
30
|
+
with(
|
31
|
+
:body => data_bag_create_payload ).
|
32
|
+
to_return(
|
33
|
+
:status => status,
|
34
|
+
:body => data_bag_create_response
|
35
|
+
)
|
36
|
+
when 409
|
37
|
+
stub_request(:post, "http://localhost:4000/data").
|
38
|
+
with(
|
39
|
+
:body => data_bag_create_payload ).
|
40
|
+
to_return(
|
41
|
+
:status => status,
|
42
|
+
:body => data_bag_conflict
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def stub_data_bag_delete(status=200)
|
48
|
+
case status
|
49
|
+
when 200
|
50
|
+
stub_request(:delete, "http://localhost:4000/data/users").
|
51
|
+
with(:body => "").
|
52
|
+
to_return(
|
53
|
+
:status => status,
|
54
|
+
:body => data_bag_delete_response
|
55
|
+
)
|
56
|
+
when 404
|
57
|
+
stub_request(:delete, "http://localhost:4000/data/users").
|
58
|
+
with(:body => "").
|
59
|
+
to_return(
|
60
|
+
:status => status,
|
61
|
+
:body => data_bag_not_found
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# payloads and responses
|
67
|
+
|
68
|
+
def data_bag_list_response
|
69
|
+
{ "users" => "http://localhost:4000/data/users",
|
70
|
+
"applications" => "http://localhost:4000/data/applications" }
|
71
|
+
end
|
72
|
+
|
73
|
+
def data_bag_show_response
|
74
|
+
{ "adam" => "http://localhost:4000/data/users/adam" }
|
75
|
+
end
|
76
|
+
|
77
|
+
def data_bag_delete_response
|
78
|
+
{ "name" => "users", "json_class" => "Chef::DataBag", "chef_type" => "data_bag" }
|
79
|
+
end
|
80
|
+
|
81
|
+
def data_bag_not_found
|
82
|
+
{ "error" => [ "Could not load data bag users" ] }
|
83
|
+
end
|
84
|
+
|
85
|
+
def data_bag_conflict
|
86
|
+
{ "error" => [ "Data bag already exists" ] }
|
87
|
+
end
|
88
|
+
|
89
|
+
def data_bag_create_payload
|
90
|
+
{ "name" => "users" }
|
91
|
+
end
|
92
|
+
|
93
|
+
def data_bag_create_response
|
94
|
+
{ "uri" => "http://localhost:4000/data/users" }
|
95
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
RSpec::Matchers.define :respond_with do |code|
|
2
|
+
match do |response|
|
3
|
+
response.code == code
|
4
|
+
end
|
5
|
+
|
6
|
+
failure_message_for_should do |code|
|
7
|
+
"expected to respond_with #{code}"
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message_for_should_not do |code|
|
11
|
+
"expected to not respond with #{code}"
|
12
|
+
end
|
13
|
+
|
14
|
+
description do
|
15
|
+
"respond with #{code}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec::Matchers.define :have_body do |body|
|
20
|
+
match do |response|
|
21
|
+
response.body == body
|
22
|
+
end
|
23
|
+
|
24
|
+
failure_message_for_should do |body|
|
25
|
+
"expected to have a body of #{body}"
|
26
|
+
end
|
27
|
+
|
28
|
+
failure_message_for_should_not do |body|
|
29
|
+
"expected to not have a body of #{body}"
|
30
|
+
end
|
31
|
+
|
32
|
+
description do
|
33
|
+
"have a valid response body"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# RSpec::Matchers.define :have_header do |header|
|
38
|
+
# match do |response|
|
39
|
+
# response.headers.has_key?(header.to_sym)
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# failure_message_for_should do |header|
|
43
|
+
# "expected to have a header #{header}"
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# failure_message_for_should_not do |header|
|
47
|
+
# "expected to not have a header #{header}"
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# description do
|
51
|
+
# "have a header #{header}"
|
52
|
+
# end
|
53
|
+
# end
|
data/spec/support/vcr.rb
CHANGED
File without changes
|
data/spice.gemspec
CHANGED
File without changes
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Dan Ryan
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-25 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -154,9 +154,11 @@ extensions: []
|
|
154
154
|
extra_rdoc_files: []
|
155
155
|
|
156
156
|
files:
|
157
|
+
- .DS_Store
|
157
158
|
- .document
|
158
159
|
- .gitignore
|
159
160
|
- .rspec
|
161
|
+
- CHANGELOG.md
|
160
162
|
- Gemfile
|
161
163
|
- Gemfile.lock
|
162
164
|
- LICENSE.txt
|
@@ -175,6 +177,7 @@ files:
|
|
175
177
|
- lib/spice/connection.rb
|
176
178
|
- lib/spice/cookbook.rb
|
177
179
|
- lib/spice/data_bag.rb
|
180
|
+
- lib/spice/mock.rb
|
178
181
|
- lib/spice/node.rb
|
179
182
|
- lib/spice/role.rb
|
180
183
|
- lib/spice/version.rb
|
@@ -189,8 +192,12 @@ files:
|
|
189
192
|
- spec/spice/node_spec.rb
|
190
193
|
- spec/spice/role_spec.rb
|
191
194
|
- spec/spice_spec.rb
|
192
|
-
- spec/support/
|
195
|
+
- spec/support/client_requests.rb
|
196
|
+
- spec/support/cookbook_requests.rb
|
197
|
+
- spec/support/data_bag_item_requests.rb
|
198
|
+
- spec/support/data_bag_requests.rb
|
193
199
|
- spec/support/requests.rb
|
200
|
+
- spec/support/respond_with_matcher.rb
|
194
201
|
- spec/support/vcr.rb
|
195
202
|
- spice.gemspec
|
196
203
|
has_rdoc: true
|
@@ -239,6 +246,10 @@ test_files:
|
|
239
246
|
- spec/spice/node_spec.rb
|
240
247
|
- spec/spice/role_spec.rb
|
241
248
|
- spec/spice_spec.rb
|
242
|
-
- spec/support/
|
249
|
+
- spec/support/client_requests.rb
|
250
|
+
- spec/support/cookbook_requests.rb
|
251
|
+
- spec/support/data_bag_item_requests.rb
|
252
|
+
- spec/support/data_bag_requests.rb
|
243
253
|
- spec/support/requests.rb
|
254
|
+
- spec/support/respond_with_matcher.rb
|
244
255
|
- spec/support/vcr.rb
|