docker-api 1.11.0 → 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/docker-api.gemspec +2 -1
- data/lib/docker/image.rb +1 -1
- data/lib/docker/util.rb +2 -1
- data/lib/docker/version.rb +1 -1
- data/spec/docker/connection_spec.rb +9 -7
- data/spec/docker/container_spec.rb +38 -38
- data/spec/docker/event_spec.rb +4 -4
- data/spec/docker/image_spec.rb +29 -27
- data/spec/docker/util_spec.rb +18 -2
- data/spec/docker_spec.rb +15 -12
- data/spec/spec_helper.rb +2 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c825c19470641dddbfb22ffd3d9ea6e18d460ee5
|
4
|
+
data.tar.gz: bb27f66ef99c3f67bc6d6ccf5929131cbc0e60b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 926b20f1d2d77d45e374acfe49a323e15c75304da91b2460ddad4d748c77724196381c8273b6aca45741d86a6519da3ba64d393db72bb8dbfcd631c0ebd558f0
|
7
|
+
data.tar.gz: 7cc64f84f7ef5ac175322e2f999b9d77cd0a35d2bedb595109cd1aabc198bd100601eaca8fc41dc3369ca86bdf32d61734691c45bb041460bff2a05e9c6481e1
|
data/.travis.yml
CHANGED
data/docker-api.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency 'json'
|
19
19
|
gem.add_dependency 'archive-tar-minitar'
|
20
20
|
gem.add_development_dependency 'rake'
|
21
|
-
gem.add_development_dependency 'rspec'
|
21
|
+
gem.add_development_dependency 'rspec', '~> 3.0'
|
22
|
+
gem.add_development_dependency 'rspec-its'
|
22
23
|
gem.add_development_dependency 'cane'
|
23
24
|
gem.add_development_dependency 'pry'
|
24
25
|
gem.add_development_dependency 'vcr', '>= 2.7.0'
|
data/lib/docker/image.rb
CHANGED
data/lib/docker/util.rb
CHANGED
@@ -35,7 +35,8 @@ module Docker::Util
|
|
35
35
|
|
36
36
|
def create_dir_tar(directory)
|
37
37
|
cwd = FileUtils.pwd
|
38
|
-
|
38
|
+
tempfile_name = Dir::Tmpname.create('out') {}
|
39
|
+
tempfile = File.open(tempfile_name, 'w+')
|
39
40
|
FileUtils.cd(directory)
|
40
41
|
Archive::Tar::Minitar.pack('.', tempfile)
|
41
42
|
File.new(tempfile.path, 'r')
|
data/lib/docker/version.rb
CHANGED
@@ -36,8 +36,8 @@ describe Docker::Connection do
|
|
36
36
|
|
37
37
|
context 'and the second argument is a Hash' do
|
38
38
|
it 'sets the url and options' do
|
39
|
-
subject.url.
|
40
|
-
subject.options.
|
39
|
+
expect(subject.url).to eq url
|
40
|
+
expect(subject.options).to eq options
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -70,19 +70,21 @@ describe Docker::Connection do
|
|
70
70
|
}
|
71
71
|
|
72
72
|
before do
|
73
|
-
subject.
|
74
|
-
resource.
|
73
|
+
allow(subject).to receive(:resource).and_return(resource)
|
74
|
+
expect(resource).to receive(:request).
|
75
|
+
with(expected_hash).
|
76
|
+
and_return(response)
|
75
77
|
end
|
76
78
|
|
77
79
|
it 'sends #request to #resource with the compiled params' do
|
78
|
-
subject.request(method, path, query, options).
|
80
|
+
expect(subject.request(method, path, query, options)).to eq body
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
84
|
[:get, :put, :post, :delete].each do |method|
|
83
85
|
describe "##{method}" do
|
84
86
|
it 'is delegated to #request' do
|
85
|
-
subject.
|
87
|
+
expect(subject).to receive(:request).with(method)
|
86
88
|
subject.public_send(method)
|
87
89
|
end
|
88
90
|
end
|
@@ -97,7 +99,7 @@ describe Docker::Connection do
|
|
97
99
|
subject { described_class.new(url, options) }
|
98
100
|
|
99
101
|
it 'returns a pretty version with the url and port' do
|
100
|
-
subject.to_s.
|
102
|
+
expect(subject.to_s).to eq expected_string
|
101
103
|
end
|
102
104
|
end
|
103
105
|
end
|
@@ -28,8 +28,8 @@ describe Docker::Container do
|
|
28
28
|
let(:description) { subject.json }
|
29
29
|
|
30
30
|
it 'returns the description as a Hash', :vcr do
|
31
|
-
description.
|
32
|
-
description['ID'].
|
31
|
+
expect(description).to be_a Hash
|
32
|
+
expect(description['ID']).to start_with(subject.id)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -39,16 +39,16 @@ describe Docker::Container do
|
|
39
39
|
context "when not selecting any stream" do
|
40
40
|
let(:non_destination) { subject.logs }
|
41
41
|
it 'returns the error message', :vcr do
|
42
|
-
non_destination.
|
43
|
-
non_destination.
|
42
|
+
expect(non_destination).to be_a String
|
43
|
+
expect(non_destination).to match /You must choose at least one/
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
context "when selecting stdout" do
|
48
48
|
let(:stdout) { subject.logs(stdout: 1) }
|
49
49
|
it 'returns blank logs', :vcr do
|
50
|
-
stdout.
|
51
|
-
stdout.
|
50
|
+
expect(stdout).to be_a String
|
51
|
+
expect(stdout).to eq ""
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -62,7 +62,7 @@ describe Docker::Container do
|
|
62
62
|
let(:opts) { {"name" => "bob"} }
|
63
63
|
|
64
64
|
it 'should have name set to bob', :vcr do
|
65
|
-
subject.json["Name"].
|
65
|
+
expect(subject.json["Name"]).to eq "/bob"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -76,7 +76,7 @@ describe Docker::Container do
|
|
76
76
|
before { subject.tap(&:start).tap(&:wait) }
|
77
77
|
|
78
78
|
it 'returns the changes as an array', :vcr do
|
79
|
-
changes.
|
79
|
+
expect(changes).to eq [
|
80
80
|
{
|
81
81
|
"Path" => "/dev",
|
82
82
|
"Kind" => 0
|
@@ -102,9 +102,9 @@ describe Docker::Container do
|
|
102
102
|
let!(:container) { image.run('/while') }
|
103
103
|
|
104
104
|
it 'returns the top commands as an Array', :vcr do
|
105
|
-
top.
|
106
|
-
top.
|
107
|
-
top.first.keys.
|
105
|
+
expect(top).to be_a Array
|
106
|
+
expect(top).to_not be_empty
|
107
|
+
expect(top.first.keys).to eq %w(UID PID PPID C STIME TTY TIME CMD)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -117,7 +117,7 @@ describe Docker::Container do
|
|
117
117
|
|
118
118
|
context 'when the file does not exist' do
|
119
119
|
it 'raises an error', :vcr do
|
120
|
-
|
120
|
+
skip 'Docker no longer returns a 500 when the file does not exist'
|
121
121
|
expect { subject.copy('/lol/not/a/real/file') { |chunk| puts chunk } }
|
122
122
|
.to raise_error
|
123
123
|
end
|
@@ -137,7 +137,7 @@ describe Docker::Container do
|
|
137
137
|
chunks = []
|
138
138
|
subject.copy('/etc/vim') { |chunk| chunks << chunk }
|
139
139
|
chunks = chunks.join("\n")
|
140
|
-
%w[vimrc vimrc.tiny].
|
140
|
+
expect(%w[vimrc vimrc.tiny]).to be_all { |file| chunks.include?(file) }
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
@@ -155,7 +155,7 @@ describe Docker::Container do
|
|
155
155
|
subject.export do |chunk|
|
156
156
|
first ||= chunk
|
157
157
|
end
|
158
|
-
first[257..261].
|
158
|
+
expect(first[257..261]).to eq "ustar" # Make sure the export is a tar.
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
@@ -198,7 +198,7 @@ describe Docker::Container do
|
|
198
198
|
# VCR, so it is currently pending until a good way to test it without
|
199
199
|
# a running Docker daemon is discovered
|
200
200
|
it 'yields the output' do
|
201
|
-
|
201
|
+
skip 'HTTP socket hijacking not compatible with VCR'
|
202
202
|
container = described_class.create(
|
203
203
|
'Cmd' => %w[cat],
|
204
204
|
'Image' => 'base',
|
@@ -226,8 +226,8 @@ describe Docker::Container do
|
|
226
226
|
before { subject.start('Binds' => ["/tmp:/foo"]) }
|
227
227
|
|
228
228
|
it 'starts the container', :vcr do
|
229
|
-
all.map(&:id).
|
230
|
-
subject.wait(10)['StatusCode'].
|
229
|
+
expect(all.map(&:id)).to be_any { |id| id.start_with?(subject.id) }
|
230
|
+
expect(subject.wait(10)['StatusCode']).to be_zero
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
@@ -237,10 +237,10 @@ describe Docker::Container do
|
|
237
237
|
before { subject.tap(&:start).stop('timeout' => '10') }
|
238
238
|
|
239
239
|
it 'stops the container', :vcr do
|
240
|
-
described_class.all(:all => true).map(&:id).
|
240
|
+
expect(described_class.all(:all => true).map(&:id)).to be_any { |id|
|
241
241
|
id.start_with?(subject.id)
|
242
242
|
}
|
243
|
-
described_class.all.map(&:id).
|
243
|
+
expect(described_class.all.map(&:id)).to be_none { |id|
|
244
244
|
id.start_with?(subject.id)
|
245
245
|
}
|
246
246
|
end
|
@@ -251,10 +251,10 @@ describe Docker::Container do
|
|
251
251
|
|
252
252
|
it 'kills the container', :vcr do
|
253
253
|
subject.kill
|
254
|
-
described_class.all.map(&:id).
|
254
|
+
expect(described_class.all.map(&:id)).to be_none { |id|
|
255
255
|
id.start_with?(subject.id)
|
256
256
|
}
|
257
|
-
described_class.all(:all => true).map(&:id).
|
257
|
+
expect(described_class.all(:all => true).map(&:id)).to be_any { |id|
|
258
258
|
id.start_with?(subject.id)
|
259
259
|
}
|
260
260
|
end
|
@@ -265,7 +265,7 @@ describe Docker::Container do
|
|
265
265
|
|
266
266
|
it 'deletes the container', :vcr do
|
267
267
|
subject.delete(:force => true)
|
268
|
-
described_class.all.map(&:id).
|
268
|
+
expect(described_class.all.map(&:id)).to be_none { |id|
|
269
269
|
id.start_with?(subject.id)
|
270
270
|
}
|
271
271
|
end
|
@@ -277,15 +277,15 @@ describe Docker::Container do
|
|
277
277
|
before { subject.start }
|
278
278
|
|
279
279
|
it 'restarts the container', :vcr do
|
280
|
-
described_class.all.map(&:id).
|
280
|
+
expect(described_class.all.map(&:id)).to be_any { |id|
|
281
281
|
id.start_with?(subject.id)
|
282
282
|
}
|
283
283
|
subject.stop
|
284
|
-
described_class.all.map(&:id).
|
284
|
+
expect(described_class.all.map(&:id)).to be_none { |id|
|
285
285
|
id.start_with?(subject.id)
|
286
286
|
}
|
287
287
|
subject.restart('timeout' => '10')
|
288
|
-
described_class.all.map(&:id).
|
288
|
+
expect(described_class.all.map(&:id)).to be_any { |id|
|
289
289
|
id.start_with?(subject.id)
|
290
290
|
}
|
291
291
|
end
|
@@ -298,7 +298,7 @@ describe Docker::Container do
|
|
298
298
|
before { subject.start }
|
299
299
|
|
300
300
|
it 'waits for the command to finish', :vcr do
|
301
|
-
subject.wait['StatusCode'].
|
301
|
+
expect(subject.wait['StatusCode']).to_not be_zero
|
302
302
|
end
|
303
303
|
|
304
304
|
context 'when an argument is given' do
|
@@ -306,12 +306,12 @@ describe Docker::Container do
|
|
306
306
|
'Image' => 'base') }
|
307
307
|
|
308
308
|
it 'sets the :read_timeout to that amount of time', :vcr do
|
309
|
-
subject.wait(6)['StatusCode'].
|
309
|
+
expect(subject.wait(6)['StatusCode']).to be_zero
|
310
310
|
end
|
311
311
|
|
312
312
|
context 'and a command runs for too long' do
|
313
313
|
it 'raises a ServerError', :vcr do
|
314
|
-
|
314
|
+
skip "VCR doesn't like to record errors"
|
315
315
|
expect { subject.wait(4) }.to raise_error(Docker::Error::TimeoutError)
|
316
316
|
end
|
317
317
|
end
|
@@ -335,7 +335,7 @@ describe Docker::Container do
|
|
335
335
|
'Image' => 'base') }
|
336
336
|
|
337
337
|
it 'creates a new container to run the specified command', :vcr do
|
338
|
-
run_command.wait['StatusCode'].
|
338
|
+
expect(run_command.wait['StatusCode']).to be_zero
|
339
339
|
end
|
340
340
|
end
|
341
341
|
end
|
@@ -347,14 +347,14 @@ describe Docker::Container do
|
|
347
347
|
before { subject.start }
|
348
348
|
|
349
349
|
it 'creates a new Image from the Container\'s changes', :vcr do
|
350
|
-
image.
|
351
|
-
image.id.
|
350
|
+
expect(image).to be_a Docker::Image
|
351
|
+
expect(image.id).to_not be_nil
|
352
352
|
end
|
353
353
|
|
354
354
|
context 'if run is passed, it saves the command in the image', :vcr do
|
355
355
|
let(:image) { subject.commit }
|
356
356
|
it 'saves the command' do
|
357
|
-
|
357
|
+
skip 'This is no longer working in v0.8'
|
358
358
|
expect(image.run('pwd').attach).to eql [["/\n"],[]]
|
359
359
|
end
|
360
360
|
end
|
@@ -405,9 +405,9 @@ describe Docker::Container do
|
|
405
405
|
let(:container) { subject.create(options) }
|
406
406
|
|
407
407
|
it 'sets the id', :vcr do
|
408
|
-
container.
|
409
|
-
container.id.
|
410
|
-
container.connection.
|
408
|
+
expect(container).to be_a Docker::Container
|
409
|
+
expect(container.id).to_not be_nil
|
410
|
+
expect(container.connection).to_not be_nil
|
411
411
|
end
|
412
412
|
end
|
413
413
|
end
|
@@ -436,7 +436,7 @@ describe Docker::Container do
|
|
436
436
|
let(:container) { subject.create('Cmd' => ['ls'], 'Image' => 'base') }
|
437
437
|
|
438
438
|
it 'materializes the Container into a Docker::Container', :vcr do
|
439
|
-
subject.get(container.id).
|
439
|
+
expect(subject.get(container.id)).to be_a Docker::Container
|
440
440
|
end
|
441
441
|
end
|
442
442
|
|
@@ -465,10 +465,10 @@ describe Docker::Container do
|
|
465
465
|
before { described_class.create('Cmd' => ['ls'], 'Image' => 'base') }
|
466
466
|
|
467
467
|
it 'materializes each Container into a Docker::Container', :vcr do
|
468
|
-
subject.all(:all => true).
|
468
|
+
expect(subject.all(:all => true)).to be_all { |container|
|
469
469
|
container.is_a?(Docker::Container)
|
470
470
|
}
|
471
|
-
subject.all(:all => true).length.
|
471
|
+
expect(subject.all(:all => true).length).to_not be_zero
|
472
472
|
end
|
473
473
|
end
|
474
474
|
end
|
data/spec/docker/event_spec.rb
CHANGED
@@ -21,8 +21,8 @@ describe Docker::Event do
|
|
21
21
|
|
22
22
|
describe ".stream" do
|
23
23
|
it 'receives three events', :vcr do
|
24
|
-
|
25
|
-
Docker::Event.
|
24
|
+
skip "get VCR to record events that break"
|
25
|
+
expect(Docker::Event).to receive(:new_event).exactly(3).times
|
26
26
|
.and_call_original
|
27
27
|
fork do
|
28
28
|
sleep 1
|
@@ -41,8 +41,8 @@ describe Docker::Event do
|
|
41
41
|
let!(:time) { Time.now.to_i }
|
42
42
|
|
43
43
|
it 'receives three events', :vcr do
|
44
|
-
|
45
|
-
Docker::Event.
|
44
|
+
skip "get VCR to record events that break"
|
45
|
+
expect(Docker::Event).to receive(:new_event).exactly(3).times
|
46
46
|
.and_call_original
|
47
47
|
fork do
|
48
48
|
sleep 1
|
data/spec/docker/image_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Docker::Image do
|
|
26
26
|
|
27
27
|
it 'removes the Image', :vcr do
|
28
28
|
subject.remove(:force => true)
|
29
|
-
Docker::Image.all.map(&:id).
|
29
|
+
expect(Docker::Image.all.map(&:id)).to_not include(id)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -159,7 +159,7 @@ describe Docker::Image do
|
|
159
159
|
|
160
160
|
it 'tags the image with the repo name', :vcr do
|
161
161
|
subject.tag(:repo => :base2, :force => true)
|
162
|
-
subject.info['RepoTags'].
|
162
|
+
expect(subject.info['RepoTags']).to include 'base2:latest'
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
@@ -168,8 +168,8 @@ describe Docker::Image do
|
|
168
168
|
let(:json) { subject.json }
|
169
169
|
|
170
170
|
it 'returns additional information about image image', :vcr do
|
171
|
-
json.
|
172
|
-
json.length.
|
171
|
+
expect(json).to be_a Hash
|
172
|
+
expect(json.length).to_not be_zero
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
@@ -178,9 +178,9 @@ describe Docker::Image do
|
|
178
178
|
let(:history) { subject.history }
|
179
179
|
|
180
180
|
it 'returns the history of the Image', :vcr do
|
181
|
-
history.
|
182
|
-
history.length.
|
183
|
-
history.
|
181
|
+
expect(history).to be_a Array
|
182
|
+
expect(history.length).to_not be_zero
|
183
|
+
expect(history).to be_all { |elem| elem.is_a? Hash }
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
@@ -218,7 +218,7 @@ describe Docker::Image do
|
|
218
218
|
subject { container.commit('run' => {"Cmd" => %w[pwd]}) }
|
219
219
|
|
220
220
|
it 'should normally show result if image has Cmd configured' do
|
221
|
-
|
221
|
+
skip 'The docs say this should work, but it clearly does not'
|
222
222
|
expect(output).to eql [["/\n"],[]]
|
223
223
|
end
|
224
224
|
end
|
@@ -231,7 +231,7 @@ describe Docker::Image do
|
|
231
231
|
it 'updates the @info hash', :vcr do
|
232
232
|
size = image.info.size
|
233
233
|
image.refresh!
|
234
|
-
image.info.size.
|
234
|
+
expect(image.info.size).to be > size
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
@@ -251,12 +251,12 @@ describe Docker::Image do
|
|
251
251
|
before { Docker.creds = creds }
|
252
252
|
|
253
253
|
it 'sets the id and sends Docker.creds', :vcr do
|
254
|
-
image.
|
255
|
-
image.id.
|
256
|
-
image.id.
|
257
|
-
image.id.
|
258
|
-
image.id.
|
259
|
-
image.info[:headers].keys.
|
254
|
+
expect(image).to be_a Docker::Image
|
255
|
+
expect(image.id).to match(/\A[a-fA-F0-9]+\Z/)
|
256
|
+
expect(image.id).to_not include('base')
|
257
|
+
expect(image.id).to_not be_nil
|
258
|
+
expect(image.id).to_not be_empty
|
259
|
+
expect(image.info[:headers].keys).to include 'X-Registry-Auth'
|
260
260
|
end
|
261
261
|
end
|
262
262
|
end
|
@@ -308,12 +308,14 @@ describe Docker::Image do
|
|
308
308
|
let(:file) { 'spec/fixtures/export.tar' }
|
309
309
|
let(:body) { StringIO.new }
|
310
310
|
|
311
|
-
before
|
311
|
+
before do
|
312
|
+
allow(Docker::Image).to receive(:open).with(file).and_yield(body)
|
313
|
+
end
|
312
314
|
|
313
315
|
it 'creates the Image', :vcr do
|
314
316
|
import = subject.import(file)
|
315
|
-
import.
|
316
|
-
import.id.
|
317
|
+
expect(import).to be_a Docker::Image
|
318
|
+
expect(import.id).to_not be_nil
|
317
319
|
end
|
318
320
|
end
|
319
321
|
|
@@ -330,8 +332,8 @@ describe Docker::Image do
|
|
330
332
|
|
331
333
|
it 'returns an Image', :vcr do
|
332
334
|
image = subject.import(uri)
|
333
|
-
image.
|
334
|
-
image.id.
|
335
|
+
expect(image).to be_a Docker::Image
|
336
|
+
expect(image.id).to_not be_nil
|
335
337
|
end
|
336
338
|
end
|
337
339
|
end
|
@@ -345,18 +347,18 @@ describe Docker::Image do
|
|
345
347
|
|
346
348
|
it 'materializes each Image into a Docker::Image', :vcr do
|
347
349
|
images.each do |image|
|
348
|
-
image.
|
350
|
+
expect(image).to_not be_nil
|
349
351
|
|
350
|
-
image.
|
352
|
+
expect(image).to be_a(described_class)
|
351
353
|
|
352
|
-
image.id.
|
354
|
+
expect(image.id).to_not be_nil
|
353
355
|
|
354
356
|
%w(Created Size VirtualSize).each do |key|
|
355
|
-
image.info.
|
357
|
+
expect(image.info).to have_key(key)
|
356
358
|
end
|
357
359
|
end
|
358
360
|
|
359
|
-
images.length.
|
361
|
+
expect(images.length).to_not be_zero
|
360
362
|
end
|
361
363
|
end
|
362
364
|
|
@@ -364,7 +366,7 @@ describe Docker::Image do
|
|
364
366
|
subject { described_class }
|
365
367
|
|
366
368
|
it 'materializes each Image into a Docker::Image', :vcr do
|
367
|
-
subject.search('term' => 'sshd').
|
369
|
+
expect(subject.search('term' => 'sshd')).to be_all { |image|
|
368
370
|
!image.id.nil? && image.is_a?(described_class)
|
369
371
|
}
|
370
372
|
end
|
@@ -471,7 +473,7 @@ describe Docker::Image do
|
|
471
473
|
before { Docker.creds = creds }
|
472
474
|
|
473
475
|
it 'sends Docker.creds', :vcr do
|
474
|
-
image.info[:headers].keys.
|
476
|
+
expect(image.info[:headers].keys).to include('X-Registry-Auth')
|
475
477
|
end
|
476
478
|
end
|
477
479
|
end
|
data/spec/docker/util_spec.rb
CHANGED
@@ -36,7 +36,7 @@ describe Docker::Util do
|
|
36
36
|
let(:arg) { '{"yolo":"swag"}' }
|
37
37
|
|
38
38
|
it 'parses the JSON into a Hash' do
|
39
|
-
subject.
|
39
|
+
expect(subject).to eq 'yolo' => 'swag'
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -46,7 +46,7 @@ describe Docker::Util do
|
|
46
46
|
subject { Docker::Util.fix_json(response) }
|
47
47
|
|
48
48
|
it 'fixes the "JSON" response that Docker returns' do
|
49
|
-
subject.
|
49
|
+
expect(subject).to eq [
|
50
50
|
{
|
51
51
|
'this' => 'is'
|
52
52
|
},
|
@@ -57,6 +57,22 @@ describe Docker::Util do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
describe '.create_dir_tar' do
|
61
|
+
attr_accessor :tmpdir
|
62
|
+
|
63
|
+
around do |example|
|
64
|
+
Dir.mktmpdir do |tmpdir|
|
65
|
+
self.tmpdir = tmpdir
|
66
|
+
example.call
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
specify do
|
71
|
+
tar = subject.create_dir_tar tmpdir
|
72
|
+
expect { FileUtils.rm tar }.to_not raise_error
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
60
76
|
describe '.build_auth_header' do
|
61
77
|
subject { described_class }
|
62
78
|
|
data/spec/docker_spec.rb
CHANGED
@@ -76,12 +76,13 @@ describe Docker do
|
|
76
76
|
|
77
77
|
[:options=, :url=].each do |method|
|
78
78
|
describe "##{method}" do
|
79
|
-
|
80
|
-
subject.
|
81
|
-
subject.
|
79
|
+
before do
|
80
|
+
subject.url = nil
|
81
|
+
subject.options = nil
|
82
82
|
end
|
83
|
+
|
83
84
|
it 'calls #reset_connection!' do
|
84
|
-
subject.
|
85
|
+
expect(subject).to receive(:reset_connection!)
|
85
86
|
subject.public_send(method, {})
|
86
87
|
end
|
87
88
|
end
|
@@ -96,8 +97,8 @@ describe Docker do
|
|
96
97
|
|
97
98
|
let(:version) { subject.version }
|
98
99
|
it 'returns the version as a Hash', :vcr do
|
99
|
-
version.
|
100
|
-
version.keys.sort.
|
100
|
+
expect(version).to be_a Hash
|
101
|
+
expect(version.keys.sort).to eq expected
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
@@ -115,8 +116,8 @@ describe Docker do
|
|
115
116
|
end
|
116
117
|
|
117
118
|
it 'returns the info as a Hash', :vcr do
|
118
|
-
info.
|
119
|
-
info.keys.sort.
|
119
|
+
expect(info).to be_a Hash
|
120
|
+
expect(info.keys.sort).to eq keys
|
120
121
|
end
|
121
122
|
end
|
122
123
|
|
@@ -144,7 +145,7 @@ describe Docker do
|
|
144
145
|
}
|
145
146
|
|
146
147
|
it 'logs in and sets the creds', :vcr do
|
147
|
-
expect(authentication).to
|
148
|
+
expect(authentication).to be true
|
148
149
|
expect(Docker.creds).to eq(credentials.to_json)
|
149
150
|
end
|
150
151
|
end
|
@@ -162,7 +163,7 @@ describe Docker do
|
|
162
163
|
}
|
163
164
|
|
164
165
|
it "raises an error and doesn't set the creds", :vcr do
|
165
|
-
|
166
|
+
skip "VCR won't record when Excon::Expects fail"
|
166
167
|
expect {
|
167
168
|
authentication
|
168
169
|
}.to raise_error(Docker::Error::AuthenticationError)
|
@@ -178,7 +179,9 @@ describe Docker do
|
|
178
179
|
end
|
179
180
|
|
180
181
|
context 'when a Docker Error is raised' do
|
181
|
-
before
|
182
|
+
before do
|
183
|
+
allow(Docker).to receive(:info).and_raise(Docker::Error::ClientError)
|
184
|
+
end
|
182
185
|
|
183
186
|
it 'raises a Version Error' do
|
184
187
|
expect { subject.validate_version! }
|
@@ -187,7 +190,7 @@ describe Docker do
|
|
187
190
|
end
|
188
191
|
|
189
192
|
context 'when nothing is raised', :vcr do
|
190
|
-
its(:validate_version!) { should
|
193
|
+
its(:validate_version!) { should be true }
|
191
194
|
end
|
192
195
|
end
|
193
196
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
|
3
3
|
require 'rspec'
|
4
|
+
require 'rspec/its'
|
4
5
|
require 'simplecov'
|
5
6
|
require 'docker'
|
6
7
|
|
@@ -8,8 +9,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
8
9
|
|
9
10
|
RSpec.configure do |config|
|
10
11
|
config.mock_with :rspec
|
11
|
-
config.
|
12
|
-
config.color_enabled = true
|
12
|
+
config.color = true
|
13
13
|
config.formatter = :documentation
|
14
14
|
config.tty = true
|
15
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swipely, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -68,6 +68,20 @@ dependencies:
|
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-its
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - '>='
|