docker-api 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/README.md +2 -0
  2. data/lib/docker.rb +12 -2
  3. data/lib/docker/connection.rb +42 -49
  4. data/lib/docker/container.rb +12 -20
  5. data/lib/docker/error.rb +3 -0
  6. data/lib/docker/image.rb +21 -47
  7. data/lib/docker/model.rb +17 -14
  8. data/lib/docker/util.rb +12 -0
  9. data/lib/docker/version.rb +5 -1
  10. data/spec/docker/connection_spec.rb +56 -30
  11. data/spec/docker/container_spec.rb +81 -201
  12. data/spec/docker/image_spec.rb +48 -157
  13. data/spec/docker/util_spec.rb +43 -0
  14. data/spec/docker_spec.rb +15 -0
  15. data/spec/vcr/Docker/_info/returns_the_info_as_a_Hash.yml +10 -8
  16. data/spec/vcr/Docker/_validate_version/when_nothing_is_raised/validate_version_/.yml +33 -0
  17. data/spec/vcr/Docker/_version/returns_the_version_as_a_Hash.yml +10 -8
  18. data/spec/vcr/Docker_Container/_all/when_the_HTTP_response_is_a_200/materializes_each_Container_into_a_Docker_Container.yml +857 -17
  19. data/spec/vcr/Docker_Container/_attach/{when_the_HTTP_response_status_is_200/yields_each_chunk.yml → yields_each_chunk.yml} +9 -9
  20. data/spec/vcr/Docker_Container/_changes/{when_the_HTTP_response_status_is_200/returns_the_changes_as_an_array.yml → returns_the_changes_as_an_array.yml} +13 -13
  21. data/spec/vcr/Docker_Container/_commit/{when_the_HTTP_response_status_is_200/creates_a_new_Image_from_the_Container_s_changes.yml → creates_a_new_Image_from_the_Container_s_changes.yml} +12 -12
  22. data/spec/vcr/Docker_Container/_create/when_the_Container_does_not_yet_exist_and_the_body_is_a_Hash/when_the_HTTP_request_returns_a_200/sets_the_id.yml +4 -4
  23. data/spec/vcr/Docker_Container/_export/{when_the_HTTP_response_status_is_200/yields_each_chunk.yml → yields_each_chunk.yml} +11 -11
  24. data/spec/vcr/Docker_Container/_json/{when_the_HTTP_response_status_is_200/returns_the_description_as_a_Hash.yml → returns_the_description_as_a_Hash.yml} +8 -8
  25. data/spec/vcr/Docker_Container/_kill/{when_the_HTTP_response_status_is_204/kills_the_container.yml → kills_the_container.yml} +436 -16
  26. data/spec/vcr/Docker_Container/_restart/{when_the_HTTP_response_status_is_204/restarts_the_container.yml → restarts_the_container.yml} +29 -29
  27. data/spec/vcr/Docker_Container/_start/{when_the_HTTP_response_status_is_200/starts_the_container.yml → starts_the_container.yml} +12 -12
  28. data/spec/vcr/Docker_Container/_stop/{when_the_HTTP_response_status_is_204/stops_the_container.yml → stops_the_container.yml} +440 -20
  29. data/spec/vcr/Docker_Container/_wait/{when_the_HTTP_response_status_is_200/waits_for_the_command_to_finish.yml → waits_for_the_command_to_finish.yml} +10 -10
  30. data/spec/vcr/Docker_Image/_all/materializes_each_Image_into_a_Docker_Image.yml +65 -0
  31. data/spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/builds_an_image.yml +9 -5
  32. data/spec/vcr/Docker_Image/_build/with_an_invalid_Dockerfile/throws_a_UnexpectedResponseError.yml +9 -5
  33. data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/builds_the_image.yml +17 -15
  34. data/spec/vcr/Docker_Image/{_create_/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash/when_the_HTTP_request_returns_a_200 → _create/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash}/sets_the_id.yml +4 -2
  35. data/spec/vcr/Docker_Image/_history/{when_the_Image_has_been_created/when_the_HTTP_response_status_is_200/returns_the_history_of_the_Image.yml → returns_the_history_of_the_Image.yml} +7 -5
  36. data/spec/vcr/Docker_Image/_import/when_the_file_does_exist/creates_the_Image.yml +6 -6
  37. data/spec/vcr/Docker_Image/_insert/{when_the_Image_has_been_created/when_the_HTTP_response_status_is_200/inserts_the_url_s_file_into_a_new_Image.yml → inserts_the_url_s_file_into_a_new_Image.yml} +30 -29
  38. data/spec/vcr/Docker_Image/_json/{when_the_Image_has_been_created/when_the_HTTP_response_status_is_200/returns_additional_information_about_image_image.yml → returns_additional_information_about_image_image.yml} +7 -5
  39. data/spec/vcr/Docker_Image/_remove/removes_the_Image.yml +95 -0
  40. data/spec/vcr/Docker_Image/_run/when_the_argument_is_a_String/splits_the_String_by_spaces_and_creates_a_new_Container.yml +14 -12
  41. data/spec/vcr/Docker_Image/_run/when_the_argument_is_an_Array/creates_a_new_Container.yml +14 -12
  42. data/spec/vcr/Docker_Image/_search/{when_the_HTTP_response_is_a_200/materializes_each_Image_into_a_Docker_Image.yml → materializes_each_Image_into_a_Docker_Image.yml} +4 -34
  43. data/spec/vcr/Docker_Image/_tag/{when_the_Image_has_been_created/when_the_HTTP_response_status_is_200/tags_the_image_with_the_repo_name.yml → tags_the_image_with_the_repo_name.yml} +7 -5
  44. metadata +43 -56
  45. data/spec/vcr/Docker_Image/_all/when_the_HTTP_response_is_a_200/materializes_each_Image_into_a_Docker_Image.yml +0 -63
  46. data/spec/vcr/Docker_Image/_create/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash/when_the_HTTP_request_returns_a_200/sets_the_id.yml +0 -33
  47. data/spec/vcr/Docker_Image/_history/when_the_HTTP_response_status_is_200/returns_the_history_of_the_Image.yml +0 -63
  48. data/spec/vcr/Docker_Image/_insert/when_the_HTTP_response_status_is_200/inserts_the_url_s_file_into_a_new_Image.yml +0 -220
  49. data/spec/vcr/Docker_Image/_json/when_the_HTTP_response_status_is_200/returns_additional_information_about_image_image.yml +0 -63
  50. data/spec/vcr/Docker_Image/_remove/when_the_HTTP_response_status_is_204/removes_the_Image.yml +0 -93
  51. data/spec/vcr/Docker_Image/_remove/when_the_Image_has_been_created/when_the_HTTP_response_status_is_204/nils_out_the_id.yml +0 -63
  52. data/spec/vcr/Docker_Image/_remove/when_the_Image_has_been_created/when_the_HTTP_response_status_is_204/removes_the_Image.yml +0 -63
  53. data/spec/vcr/Docker_Image/_run/when_the_Image_has_been_created/when_the_argument_is_a_String/splits_the_String_by_spaces_and_creates_a_new_Container.yml +0 -119
  54. data/spec/vcr/Docker_Image/_run/when_the_Image_has_been_created/when_the_argument_is_an_Array/creates_a_new_Container.yml +0 -119
  55. data/spec/vcr/Docker_Image/_tag/when_the_HTTP_response_status_is_200/tags_the_image_with_the_repo_name.yml +0 -63
@@ -3,11 +3,11 @@ require 'spec_helper'
3
3
  # WARNING if you're re-recording any of these VCRs, you must be running the
4
4
  # Docker daemon and have the base Image pulled.
5
5
  describe Docker::Container do
6
- subject { described_class.send(:new, :id => rand(10000).to_s) }
7
-
8
6
  describe '#to_s' do
7
+ subject { described_class.send(:new, :id => rand(10000).to_s) }
8
+
9
9
  let(:id) { 'bf119e2' }
10
- let(:connection) { Docker::Connection.new }
10
+ let(:connection) { Docker.connection }
11
11
  let(:expected_string) {
12
12
  "Docker::Container { :id => #{id}, :connection => #{connection} }"
13
13
  }
@@ -22,259 +22,139 @@ describe Docker::Container do
22
22
  end
23
23
 
24
24
  describe '#json' do
25
- context 'when the HTTP response status is not 200' do
26
- before { Excon.stub({ :method => :get }, { :status => 500 }) }
27
- after { Excon.stubs.shift }
25
+ subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
26
+ let(:description) { subject.json }
28
27
 
29
- it 'raises an error' do
30
- expect { subject.json }
31
- .to raise_error(Docker::Error::ServerError)
32
- end
33
- end
34
-
35
- context 'when the HTTP response status is 200' do
36
- subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
37
- let(:description) { subject.json }
38
-
39
- it 'returns the description as a Hash', :vcr do
40
- description.should be_a(Hash)
41
- description['ID'].should start_with(subject.id)
42
- end
28
+ it 'returns the description as a Hash', :vcr do
29
+ description.should be_a(Hash)
30
+ description['ID'].should start_with(subject.id)
43
31
  end
44
32
  end
45
33
 
46
34
  describe '#changes' do
47
- context 'when the HTTP response status is not 200' do
48
- before { Excon.stub({ :method => :get }, { :status => 500 }) }
49
- after { Excon.stubs.shift }
35
+ subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
36
+ let(:changes) { subject.changes }
50
37
 
51
- it 'raises an error' do
52
- expect { subject.changes }
53
- .to raise_error(Docker::Error::ServerError)
54
- end
55
- end
56
-
57
- context 'when the HTTP response status is 200' do
58
- subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
59
- let(:changes) { subject.changes }
60
-
61
- before { subject.tap(&:start).tap(&:wait) }
38
+ before { subject.tap(&:start).tap(&:wait) }
62
39
 
63
- it 'returns the changes as an array', :vcr do
64
- changes.should be_a Array
65
- changes.should be_all { |change| change.is_a?(Hash) }
66
- changes.length.should_not be_zero
67
- end
40
+ it 'returns the changes as an array', :vcr do
41
+ changes.should be_a Array
42
+ changes.should be_all { |change| change.is_a?(Hash) }
43
+ changes.length.should_not be_zero
68
44
  end
69
45
  end
70
46
 
71
47
  describe '#export' do
72
- context 'when the HTTP response status is not 200' do
73
- before { Excon.stub({ :method => :get }, { :status => 500 }) }
74
- after { Excon.stubs.shift }
48
+ subject { described_class.create('Cmd' => %w[rm -rf / --no-preserve-root],
49
+ 'Image' => 'base') }
50
+ before { subject.start }
75
51
 
76
- it 'raises an error' do
77
- expect { subject.export { } }
78
- .to raise_error(Docker::Error::ServerError)
79
- end
80
- end
81
-
82
- context 'when the HTTP response status is 200' do
83
- subject {
84
- Docker::Container.create('Cmd' => %w[rm -rf / --no-preserve-root],
85
- 'Image' => 'base')
86
- }
87
- before { subject.start }
88
-
89
- it 'yields each chunk', :vcr do
90
- first = nil
91
- subject.export do |chunk|
92
- first = chunk
93
- break
94
- end
95
- first[257..261].should == "ustar" # Make sure the export is a tar.
52
+ # If you have to re-record this VCR, PLEASE edit it so that it's only ~200
53
+ # lines. This is only because we don't want our gem to be a few hundred
54
+ # megabytes.
55
+ it 'yields each chunk', :vcr do
56
+ first = nil
57
+ subject.export do |chunk|
58
+ first = chunk
59
+ break
96
60
  end
61
+ first[257..261].should == "ustar" # Make sure the export is a tar.
97
62
  end
98
63
  end
99
64
 
100
65
  describe '#attach' do
101
- context 'when the HTTP response status is not 200' do
102
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
103
- after { Excon.stubs.shift }
66
+ subject { described_class.create('Cmd' => %w[uname -r], 'Image' => 'base') }
104
67
 
105
- it 'raises an error' do
106
- expect { subject.attach { } }
107
- .to raise_error(Docker::Error::ServerError)
108
- end
109
- end
110
-
111
- context 'when the HTTP response status is 200' do
112
- subject { described_class.create('Cmd' => %w[uname -r],
113
- 'Image' => 'base') }
68
+ before { subject.start }
114
69
 
115
- it 'yields each chunk', :vcr do
116
- subject.tap(&:start).attach { |chunk|
117
- chunk.should == "3.8.0-25-generic\n"
118
- }
119
- end
70
+ it 'yields each chunk', :vcr do
71
+ subject.attach { |chunk|
72
+ chunk.should == "3.8.0-25-generic\n"
73
+ break
74
+ }
120
75
  end
121
76
  end
122
77
 
123
78
  describe '#start' do
124
- context 'when the HTTP response status is not 200' do
125
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
126
- after { Excon.stubs.shift }
127
-
128
- it 'raises an error' do
129
- expect { subject.start }
130
- .to raise_error(Docker::Error::ServerError)
131
- end
132
- end
79
+ subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
133
80
 
134
- context 'when the HTTP response status is 200' do
135
- subject {
136
- described_class.create('Cmd' => %w[true], 'Image' => 'base')
81
+ it 'starts the container', :vcr do
82
+ subject.start
83
+ described_class.all.map(&:id).should be_any { |id|
84
+ id.start_with?(subject.id)
137
85
  }
138
-
139
- it 'starts the container', :vcr do
140
- subject.start
141
- described_class.all.map(&:id).should be_any { |id|
142
- id.start_with?(subject.id)
143
- }
144
- end
145
86
  end
146
87
  end
147
88
 
148
89
  describe '#stop' do
149
- context 'when the HTTP response status is not 204' do
150
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
151
- after { Excon.stubs.shift }
90
+ subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
152
91
 
153
- it 'raises an error' do
154
- expect { subject.stop }
155
- .to raise_error(Docker::Error::ServerError)
156
- end
157
- end
92
+ before { subject.tap(&:start).stop }
158
93
 
159
- context 'when the HTTP response status is 204' do
160
- subject { described_class.create('Cmd' => %w[ls], 'Image' => 'base') }
161
-
162
- it 'stops the container', :vcr do
163
- subject.tap(&:start).stop
164
- described_class.all(:all => true).map(&:id).should be_any { |id|
165
- id.start_with?(subject.id)
166
- }
167
- described_class.all.map(&:id).should be_none { |id|
168
- id.start_with?(subject.id)
169
- }
170
- end
94
+ it 'stops the container', :vcr do
95
+ described_class.all(:all => true).map(&:id).should be_any { |id|
96
+ id.start_with?(subject.id)
97
+ }
98
+ described_class.all.map(&:id).should be_none { |id|
99
+ id.start_with?(subject.id)
100
+ }
171
101
  end
172
102
  end
173
103
 
174
104
  describe '#kill' do
175
- context 'when the HTTP response status is not 204' do
176
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
177
- after { Excon.stubs.shift }
105
+ subject { described_class.create('Cmd' => ['ls'], 'Image' => 'base') }
178
106
 
179
- it 'raises an error' do
180
- expect { subject.kill }
181
- .to raise_error(Docker::Error::ServerError)
182
- end
183
- end
184
-
185
- context 'when the HTTP response status is 204' do
186
- subject { described_class.create('Cmd' => ['ls'], 'Image' => 'base') }
187
-
188
- it 'kills the container', :vcr do
189
- subject.kill
190
- described_class.all.map(&:id).should be_none { |id|
191
- id.start_with?(subject.id)
192
- }
193
- described_class.all(:all => true).map(&:id).should be_any { |id|
194
- id.start_with?(subject.id)
195
- }
196
- end
107
+ it 'kills the container', :vcr do
108
+ subject.kill
109
+ described_class.all.map(&:id).should be_none { |id|
110
+ id.start_with?(subject.id)
111
+ }
112
+ described_class.all(:all => true).map(&:id).should be_any { |id|
113
+ id.start_with?(subject.id)
114
+ }
197
115
  end
198
116
  end
199
117
 
200
118
  describe '#restart' do
201
- context 'when the HTTP response status is not 204' do
202
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
203
- after { Excon.stubs.shift }
119
+ subject { described_class.create('Cmd' => %w[sleep 50], 'Image' => 'base') }
204
120
 
205
- it 'raises an error' do
206
- expect { subject.restart }
207
- .to raise_error(Docker::Error::ServerError)
208
- end
209
- end
121
+ before { subject.start }
210
122
 
211
- context 'when the HTTP response status is 204' do
212
- subject {
213
- described_class.create('Cmd' => %w[/usr/bin/sleep 50],
214
- 'Image' => 'base')
123
+ it 'restarts the container', :vcr do
124
+ described_class.all.map(&:id).should be_any { |id|
125
+ id.start_with?(subject.id)
126
+ }
127
+ subject.stop
128
+ described_class.all.map(&:id).should be_none { |id|
129
+ id.start_with?(subject.id)
130
+ }
131
+ subject.restart
132
+ described_class.all.map(&:id).should be_any { |id|
133
+ id.start_with?(subject.id)
215
134
  }
216
-
217
- it 'restarts the container', :vcr do
218
- subject.start
219
- described_class.all.map(&:id).should be_any { |id|
220
- id.start_with?(subject.id)
221
- }
222
- subject.stop
223
- described_class.all.map(&:id).should be_none { |id|
224
- id.start_with?(subject.id)
225
- }
226
- subject.restart
227
- described_class.all.map(&:id).should be_any { |id|
228
- id.start_with?(subject.id)
229
- }
230
- end
231
135
  end
232
136
  end
233
137
 
234
138
  describe '#wait' do
235
- context 'when the HTTP response status is not 200' do
236
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
237
- after { Excon.stubs.shift }
238
-
239
- it 'raises an error' do
240
- expect { subject.wait }
241
- .to raise_error(Docker::Error::ServerError)
242
- end
243
- end
139
+ subject { described_class.create('Cmd' => %w[tar nonsense],
140
+ 'Image' => 'base') }
244
141
 
245
- context 'when the HTTP response status is 200' do
246
- subject {
247
- described_class.create('Cmd' => %w[tar nonsense],
248
- 'Image' => 'base') }
142
+ before { subject.start }
249
143
 
250
- it 'waits for the command to finish', :vcr do
251
- subject.start
252
- subject.wait['StatusCode'].should == 64
253
- end
144
+ it 'waits for the command to finish', :vcr do
145
+ subject.wait['StatusCode'].should == 64
254
146
  end
255
147
  end
256
148
 
257
149
  describe '#commit' do
258
- context 'when the HTTP response status is not 200' do
259
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
260
- after { Excon.stubs.shift }
261
-
262
- it 'raises an error' do
263
- expect { subject.commit }
264
- .to raise_error(Docker::Error::ServerError)
265
- end
266
- end
267
-
268
- context 'when the HTTP response status is 200' do
269
- let(:image) { subject.commit }
270
- subject { described_class.create('Cmd' => %w[ls], 'Image' => 'base') }
150
+ subject { described_class.create('Cmd' => %w[true], 'Image' => 'base') }
151
+ let(:image) { subject.commit }
271
152
 
272
- before { subject.start }
153
+ before { subject.start }
273
154
 
274
- it 'creates a new Image from the Container\'s changes', :vcr do
275
- image.should be_a Docker::Image
276
- image.id.should_not be_nil
277
- end
155
+ it 'creates a new Image from the Container\'s changes', :vcr do
156
+ image.should be_a Docker::Image
157
+ image.id.should_not be_nil
278
158
  end
279
159
  end
280
160
 
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Docker::Image do
4
- subject { described_class.send(:new, :id => rand(10000).to_s) }
5
-
6
4
  describe '#to_s' do
5
+ subject { described_class.send(:new, :id => rand(10000).to_s) }
6
+
7
7
  let(:id) { 'bf119e2' }
8
- let(:connection) { Docker::Connection.new }
8
+ let(:connection) { Docker.connection }
9
9
  let(:expected_string) do
10
10
  "Docker::Image { :id => #{id}, :connection => #{connection} }"
11
11
  end
@@ -20,137 +20,62 @@ describe Docker::Image do
20
20
  end
21
21
 
22
22
  describe '#remove' do
23
- context 'when the HTTP response status is not 204' do
24
- before { Excon.stub({ :method => :delete }, { :status => 500 }) }
25
- after { Excon.stubs.shift }
23
+ let(:id) { subject.id }
24
+ subject { described_class.create('fromImage' => 'base') }
26
25
 
27
- it 'raises an error' do
28
- expect { subject.remove }
29
- .to raise_error(Docker::Error::ServerError)
30
- end
31
- end
32
-
33
- context 'when the HTTP response status is 204' do
34
- let(:id) { subject.id }
35
- subject { described_class.create('fromImage' => 'base') }
36
-
37
- it 'removes the Image', :vcr do
38
- subject.remove
39
- Docker::Image.all.map(&:id).should_not include(id)
40
- end
26
+ it 'removes the Image', :vcr do
27
+ subject.remove
28
+ Docker::Image.all.map(&:id).should_not include(id)
41
29
  end
42
30
  end
43
31
 
44
32
  describe '#insert' do
45
- context 'when the HTTP response status is not 200' do
46
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
47
- after { Excon.stubs.shift }
33
+ subject { described_class.build('from base') }
34
+ let(:new_image) { subject.insert(:path => '/stallman',
35
+ :url => 'http://stallman.org') }
36
+ let(:ls_output) { new_image.run('ls /').attach.split("\n") }
48
37
 
49
- it 'raises an error' do
50
- expect { subject.insert }
51
- .to raise_error(Docker::Error::ServerError)
52
- end
53
- end
54
-
55
- context 'when the HTTP response status is 200' do
56
- subject { described_class.build('from base') }
57
- let(:new_image) { subject.insert(:path => '/stallman',
58
- :url => 'http://stallman.org') }
59
- let(:ls_output) { new_image.run('ls /').attach.split("\n") }
60
-
61
- it 'inserts the url\'s file into a new Image', :vcr do
62
- ls_output.should include('stallman')
63
- end
38
+ it 'inserts the url\'s file into a new Image', :vcr do
39
+ ls_output.should include('stallman')
64
40
  end
65
41
  end
66
42
 
67
43
  describe '#push' do
68
- context 'when the HTTP response status is not 200' do
69
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
70
- after { Excon.stubs.shift }
71
-
72
- it 'raises an error' do
73
- expect { subject.push }
74
- .to raise_error(Docker::Error::ServerError)
75
- end
76
- end
77
-
78
- context 'when the HTTP response status is 200' do
79
- subject { described_class.create('fromImage' => 'base') }
44
+ subject { described_class.create('fromImage' => 'base') }
80
45
 
81
- it 'pushes the Image', :vcr do
82
- pending 'I don\'t want to push the Image to the Docker Registry'
83
- subject.push
84
- end
46
+ it 'pushes the Image', :vcr do
47
+ pending 'I don\'t want to push the Image to the Docker Registry'
48
+ subject.push
85
49
  end
86
50
  end
87
51
 
88
52
  describe '#tag' do
89
- context 'when the HTTP response status is not 200' do
90
- before { Excon.stub({ :method => :post }, { :status => 500 }) }
91
- after { Excon.stubs.shift }
92
-
93
- it 'raises an error' do
94
- expect { subject.tag }
95
- .to raise_error(Docker::Error::ServerError)
96
- end
97
- end
98
-
99
- context 'when the HTTP response status is 200' do
100
- subject { described_class.create('fromImage' => 'base') }
53
+ subject { described_class.create('fromImage' => 'base') }
101
54
 
102
- it 'tags the image with the repo name', :vcr do
103
- expect { subject.tag(:repo => 'base2', :force => true) }
104
- .to_not raise_error
105
- end
55
+ it 'tags the image with the repo name', :vcr do
56
+ expect { subject.tag(:repo => 'base2', :force => true) }
57
+ .to_not raise_error
106
58
  end
107
59
  end
108
60
 
109
61
  describe '#json' do
110
- context 'when the HTTP response status is not 200' do
111
- before do
112
- subject.stub(:created?).and_return(true)
113
- Excon.stub({ :method => :get }, { :status => 500 })
114
- end
115
- after { Excon.stubs.shift }
116
-
117
- it 'raises an error' do
118
- expect { subject.json }
119
- .to raise_error(Docker::Error::ServerError)
120
- end
121
- end
122
-
123
- context 'when the HTTP response status is 200' do
124
- subject { described_class.create('fromImage' => 'base') }
125
- let(:json) { subject.json }
62
+ subject { described_class.create('fromImage' => 'base') }
63
+ let(:json) { subject.json }
126
64
 
127
- it 'returns additional information about image image', :vcr do
128
- json.should be_a Hash
129
- json.length.should_not be_zero
130
- end
65
+ it 'returns additional information about image image', :vcr do
66
+ json.should be_a Hash
67
+ json.length.should_not be_zero
131
68
  end
132
69
  end
133
70
 
134
71
  describe '#history' do
135
- context 'when the HTTP response status is not 200' do
136
- before { Excon.stub({ :method => :get }, { :status => 500 }) }
137
- after { Excon.stubs.shift }
138
-
139
- it 'raises an error' do
140
- expect { subject.history }
141
- .to raise_error(Docker::Error::ServerError)
142
- end
143
- end
144
-
145
- context 'when the HTTP response status is 200' do
146
- subject { described_class.create('fromImage' => 'base') }
147
- let(:history) { subject.history }
72
+ subject { described_class.create('fromImage' => 'base') }
73
+ let(:history) { subject.history }
148
74
 
149
- it 'returns the history of the Image', :vcr do
150
- history.should be_a Array
151
- history.length.should_not be_zero
152
- history.should be_all { |elem| elem.is_a? Hash }
153
- end
75
+ it 'returns the history of the Image', :vcr do
76
+ history.should be_a Array
77
+ history.length.should_not be_zero
78
+ history.should be_all { |elem| elem.is_a? Hash }
154
79
  end
155
80
  end
156
81
 
@@ -185,21 +110,11 @@ describe Docker::Image do
185
110
  end
186
111
 
187
112
  context 'when the Image does not yet exist and the body is a Hash' do
188
- context 'when the HTTP request does not return a 200' do
189
- before { Excon.stub({ :method => :post }, { :status => 400 }) }
190
- after { Excon.stubs.shift }
191
-
192
- it 'raises an error' do
193
- expect { subject.create }.to raise_error(Docker::Error::ClientError)
194
- end
195
- end
113
+ let(:image) { subject.create('fromImage' => 'base') }
196
114
 
197
- context 'when the HTTP request returns a 200' do
198
- let(:image) { subject.create('fromImage' => 'base') }
199
- it 'sets the id', :vcr do
200
- image.should be_a Docker::Image
201
- image.id.should_not be_nil
202
- end
115
+ it 'sets the id', :vcr do
116
+ image.should be_a Docker::Image
117
+ image.id.should_not be_nil
203
118
  end
204
119
  end
205
120
  end
@@ -235,48 +150,24 @@ describe Docker::Image do
235
150
  describe '.all' do
236
151
  subject { described_class }
237
152
 
238
- context 'when the HTTP response is not a 200' do
239
- before { Excon.stub({ :method => :get }, { :status => 500 }) }
240
- after { Excon.stubs.shift }
153
+ let(:images) { subject.all(:all => true) }
154
+ before { subject.create('fromImage' => 'base') }
241
155
 
242
- it 'raises an error' do
243
- expect { subject.all }
244
- .to raise_error(Docker::Error::ServerError)
245
- end
246
- end
247
-
248
- context 'when the HTTP response is a 200' do
249
- let(:images) { subject.all(:all => true) }
250
- before { subject.create('fromImage' => 'base') }
251
-
252
- it 'materializes each Image into a Docker::Image', :vcr do
253
- images.should be_all { |image|
254
- !image.id.nil? && image.is_a?(described_class)
255
- }
256
- images.length.should_not be_zero
257
- end
156
+ it 'materializes each Image into a Docker::Image', :vcr do
157
+ images.should be_all { |image|
158
+ !image.id.nil? && image.is_a?(described_class)
159
+ }
160
+ images.length.should_not be_zero
258
161
  end
259
162
  end
260
163
 
261
164
  describe '.search' do
262
165
  subject { described_class }
263
166
 
264
- context 'when the HTTP response is not a 200' do
265
- before { Excon.stub({ :method => :get }, { :status => 500 }) }
266
- after { Excon.stubs.shift }
267
-
268
- it 'raises an error' do
269
- expect { subject.search }
270
- .to raise_error(Docker::Error::ServerError)
271
- end
272
- end
273
-
274
- context 'when the HTTP response is a 200' do
275
- it 'materializes each Image into a Docker::Image', :vcr do
276
- subject.search('term' => 'sshd').should be_all { |image|
277
- !image.id.nil? && image.is_a?(described_class)
278
- }
279
- end
167
+ it 'materializes each Image into a Docker::Image', :vcr do
168
+ subject.search('term' => 'sshd').should be_all { |image|
169
+ !image.id.nil? && image.is_a?(described_class)
170
+ }
280
171
  end
281
172
  end
282
173