docker-api 1.23.0 → 1.24.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.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.cane +1 -1
  3. data/.rspec +1 -0
  4. data/.travis.yml +7 -6
  5. data/Dockerfile +2 -0
  6. data/README.md +5 -5
  7. data/Rakefile +26 -31
  8. data/TESTING.md +7 -19
  9. data/docker-api.gemspec +0 -1
  10. data/lib/docker/image.rb +6 -2
  11. data/lib/docker/version.rb +1 -1
  12. data/spec/docker/container_spec.rb +72 -92
  13. data/spec/docker/event_spec.rb +33 -23
  14. data/spec/docker/exec_spec.rb +9 -24
  15. data/spec/docker/image_spec.rb +75 -81
  16. data/spec/docker_spec.rb +21 -32
  17. metadata +4 -200
  18. data/spec/support/vcr.rb +0 -14
  19. data/spec/vcr/Docker/_authenticate_/with_valid_credentials/logs_in_and_sets_the_creds.yml +0 -32
  20. data/spec/vcr/Docker/_info/returns_the_info_as_a_Hash.yml +0 -39
  21. data/spec/vcr/Docker/_validate_version/when_nothing_is_raised/validate_version_/.yml +0 -39
  22. data/spec/vcr/Docker/_version/returns_the_version_as_a_Hash.yml +0 -34
  23. data/spec/vcr/Docker_Container/_all/when_the_HTTP_response_is_a_200/materializes_each_Container_into_a_Docker_Container.yml +0 -125
  24. data/spec/vcr/Docker_Container/_attach/with_normal_sized_chunks/yields_each_chunk.yml +0 -125
  25. data/spec/vcr/Docker_Container/_attach/with_very_small_chunks/yields_each_chunk.yml +0 -125
  26. data/spec/vcr/Docker_Container/_changes/returns_the_changes_as_an_array.yml +0 -165
  27. data/spec/vcr/Docker_Container/_commit/creates_a_new_Image_from_the_Container_s_changes.yml +0 -165
  28. data/spec/vcr/Docker_Container/_copy/when_the_file_does_not_exist/raises_an_error.yml +0 -136
  29. data/spec/vcr/Docker_Container/_copy/when_the_input_is_a_directory/yields_each_chunk_of_the_tarred_directory.yml +0 -241
  30. data/spec/vcr/Docker_Container/_copy/when_the_input_is_a_file/yields_each_chunk_of_the_tarred_file.yml +0 -198
  31. data/spec/vcr/Docker_Container/_create/when_creating_a_container_named_bob/should_have_name_set_to_bob.yml +0 -84
  32. data/spec/vcr/Docker_Container/_create/when_the_Container_does_not_yet_exist/when_the_HTTP_request_returns_a_200/sets_the_id.yml +0 -55
  33. data/spec/vcr/Docker_Container/_delete/deletes_the_container.yml +0 -85
  34. data/spec/vcr/Docker_Container/_exec/when_detach_is_true/returns_the_Docker_Exec_object.yml +0 -180
  35. data/spec/vcr/Docker_Container/_exec/when_passed_a_block/streams_the_stdout/stderr_messages.yml +0 -183
  36. data/spec/vcr/Docker_Container/_exec/when_passed_only_a_command/returns_the_stdout/stderr_messages_and_exit_code.yml +0 -183
  37. data/spec/vcr/Docker_Container/_exec/when_stdin_object_is_passed/returns_the_stdout/stderr_messages.yml +0 -101
  38. data/spec/vcr/Docker_Container/_exec/when_tty_is_true/returns_the_raw_stdout/stderr_output.yml +0 -182
  39. data/spec/vcr/Docker_Container/_export/yields_each_chunk.yml +0 -333
  40. data/spec/vcr/Docker_Container/_get/when_the_HTTP_response_is_a_200/materializes_the_Container_into_a_Docker_Container.yml +0 -84
  41. data/spec/vcr/Docker_Container/_json/returns_the_description_as_a_Hash.yml +0 -84
  42. data/spec/vcr/Docker_Container/_kill/kills_the_container.yml +0 -164
  43. data/spec/vcr/Docker_Container/_kill/with_a_kill_signal/kills_the_container.yml +0 -257
  44. data/spec/vcr/Docker_Container/_logs/when_not_selecting_any_stream/raises_a_client_error.yml +0 -171
  45. data/spec/vcr/Docker_Container/_logs/when_selecting_stdout/returns_blank_logs.yml +0 -82
  46. data/spec/vcr/Docker_Container/_pause/pauses_the_container.yml +0 -176
  47. data/spec/vcr/Docker_Container/_rename/renames_the_container.yml +0 -149
  48. data/spec/vcr/Docker_Container/_restart/restarts_the_container.yml +0 -243
  49. data/spec/vcr/Docker_Container/_run/when_the_Container_s_command_does_not_return_status_code_of_0/raises_an_error.yml +0 -107
  50. data/spec/vcr/Docker_Container/_run/when_the_Container_s_command_returns_a_status_code_of_0/creates_a_new_container_to_run_the_specified_command.yml +0 -392
  51. data/spec/vcr/Docker_Container/_start/starts_the_container.yml +0 -140
  52. data/spec/vcr/Docker_Container/_stop/stops_the_container.yml +0 -164
  53. data/spec/vcr/Docker_Container/_streaming_logs/when_not_selecting_any_stream/raises_a_client_error.yml +0 -217
  54. data/spec/vcr/Docker_Container/_streaming_logs/when_passing_a_block/returns_hello_.yml +0 -131
  55. data/spec/vcr/Docker_Container/_streaming_logs/when_selecting_stdout/returns_blank_logs.yml +0 -131
  56. data/spec/vcr/Docker_Container/_streaming_logs/when_using_a_tty/returns_hello_.yml +0 -131
  57. data/spec/vcr/Docker_Container/_top/returns_the_top_commands_as_an_Array.yml +0 -194
  58. data/spec/vcr/Docker_Container/_unpause/unpauses_the_container.yml +0 -176
  59. data/spec/vcr/Docker_Container/_wait/waits_for_the_command_to_finish.yml +0 -107
  60. data/spec/vcr/Docker_Container/_wait/when_an_argument_is_given/sets_the_read_timeout_to_that_amount_of_time.yml +0 -107
  61. data/spec/vcr/Docker_Exec/_create/when_the_HTTP_request_returns_a_201/sets_the_id.yml +0 -130
  62. data/spec/vcr/Docker_Exec/_json/returns_the_description_as_a_Hash.yml +0 -207
  63. data/spec/vcr/Docker_Exec/_start_/when_detach_is_set_to_false/block_is_passed/attaches_to_the_stream.yml +0 -182
  64. data/spec/vcr/Docker_Exec/_start_/when_detach_is_set_to_false/returns_the_stdout_and_stderr_messages.yml +0 -182
  65. data/spec/vcr/Docker_Exec/_start_/when_detach_is_set_to_true/returns_empty_stdout/stderr_messages_with_exitcode.yml +0 -180
  66. data/spec/vcr/Docker_Exec/_start_/when_the_HTTP_request_returns_a_201/starts_the_exec_instance.yml +0 -180
  67. data/spec/vcr/Docker_Exec/_start_/when_the_command_has_already_run/raises_an_error.yml +0 -180
  68. data/spec/vcr/Docker_Exec/_start_/when_wait_set_long_time_value/returns_empty_stdout_and_stderr_messages_with_exitcode.yml +0 -189
  69. data/spec/vcr/Docker_Image/_all/materializes_each_Image_into_a_Docker_Image.yml +0 -111
  70. data/spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/with_a_block_capturing_build_output/calls_the_block_and_passes_build_output.yml +0 -75
  71. data/spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/with_specifying_a_repo_in_the_query_parameters/builds_an_image_and_tags_it.yml +0 -219
  72. data/spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/without_query_parameters/builds_an_image.yml +0 -75
  73. data/spec/vcr/Docker_Image/_build/with_an_invalid_Dockerfile/throws_a_UnexpectedResponseError.yml +0 -79
  74. data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/calls_the_block_and_passes_build_output.yml +0 -194
  75. data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/uses_a_cached_version_the_second_time/calls_the_block_and_passes_build_output.yml +0 -96
  76. data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_credentials_passed/sends_X-Registry-Config_header.yml +0 -194
  77. data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_no_query_parameters/builds_the_image.yml +0 -562
  78. data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_specifying_a_repo_in_the_query_parameters/builds_the_image_and_tags_it.yml +0 -601
  79. data/spec/vcr/Docker_Image/_create/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash/sets_the_id_and_sends_Docker_creds.yml +0 -65
  80. data/spec/vcr/Docker_Image/_create/with_a_block_capturing_create_output/calls_the_block_and_passes_build_output.yml +0 -38
  81. data/spec/vcr/Docker_Image/_exist_/when_the_image_does_exist/returns_true.yml +0 -33
  82. data/spec/vcr/Docker_Image/_get/when_the_image_does_exist/returns_the_new_image.yml +0 -33
  83. data/spec/vcr/Docker_Image/_history/returns_the_history_of_the_Image.yml +0 -66
  84. data/spec/vcr/Docker_Image/_import/when_the_argument_is_a_URI/when_the_URI_is_invalid/raises_an_error.yml +0 -265
  85. data/spec/vcr/Docker_Image/_import/when_the_argument_is_a_URI/when_the_URI_is_valid/returns_an_Image.yml +0 -303
  86. data/spec/vcr/Docker_Image/_import/when_the_file_does_exist/creates_the_Image.yml +0 -59
  87. data/spec/vcr/Docker_Image/_insert_local/when_a_direcory_is_passed/inserts_the_directory.yml +0 -1469
  88. data/spec/vcr/Docker_Image/_insert_local/when_removing_intermediate_containers/creates_a_new_image.yml +0 -244
  89. data/spec/vcr/Docker_Image/_insert_local/when_removing_intermediate_containers/leave_no_intermediate_containers.yml +0 -224
  90. data/spec/vcr/Docker_Image/_insert_local/when_the_local_file_does_exist/creates_a_new_Image_that_has_that_file.yml +0 -289
  91. data/spec/vcr/Docker_Image/_insert_local/when_the_local_file_does_not_exist/raises_an_error.yml +0 -32
  92. data/spec/vcr/Docker_Image/_insert_local/when_there_are_multiple_files_passed/creates_a_new_Image_that_has_each_file.yml +0 -366
  93. data/spec/vcr/Docker_Image/_json/returns_additional_information_about_image_image.yml +0 -62
  94. data/spec/vcr/Docker_Image/_push/pushes_the_Image.yml +0 -246
  95. data/spec/vcr/Docker_Image/_push/streams_output_from_push.yml +0 -246
  96. data/spec/vcr/Docker_Image/_push/when_the_image_was_retrived_by_get/when_no_tag_is_specified/looks_up_the_first_repo_tag.yml +0 -382
  97. data/spec/vcr/Docker_Image/_push/when_there_are_no_credentials/still_pushes.yml +0 -264
  98. data/spec/vcr/Docker_Image/_refresh_/updates_the_info_hash.yml +0 -141
  99. data/spec/vcr/Docker_Image/_refresh_/with_an_explicit_connection/updates_using_the_provided_connection.yml +0 -62
  100. data/spec/vcr/Docker_Image/_remove/when_no_name_is_given/removes_the_Image.yml +0 -652
  101. data/spec/vcr/Docker_Image/_run/when_the_argument_is_a_String/splits_the_String_by_spaces_and_creates_a_new_Container.yml +0 -162
  102. data/spec/vcr/Docker_Image/_run/when_the_argument_is_an_Array/creates_a_new_Container.yml +0 -162
  103. data/spec/vcr/Docker_Image/_run/when_the_argument_is_nil/command_configured_in_image/should_normally_show_result_if_image_has_Cmd_configured.yml +0 -162
  104. data/spec/vcr/Docker_Image/_run/when_the_argument_is_nil/no_command_configured_in_image/should_raise_an_error_if_no_command_is_specified.yml +0 -63
  105. data/spec/vcr/Docker_Image/_save/calls_the_class_method.yml +0 -67
  106. data/spec/vcr/Docker_Image/_save/when_a_filename_is_specified/exports_tarball_of_image_to_specified_file.yml +0 -176
  107. data/spec/vcr/Docker_Image/_save/when_no_filename_is_specified/returns_raw_binary_data_as_string.yml +0 -176
  108. data/spec/vcr/Docker_Image/_search/materializes_each_Image_into_a_Docker_Image.yml +0 -79
  109. data/spec/vcr/Docker_Image/_tag/tags_the_image_with_the_repo_name.yml +0 -88
@@ -20,40 +20,50 @@ describe Docker::Event do
20
20
  end
21
21
 
22
22
  describe ".stream" do
23
- it 'receives three events', :vcr do
24
- skip "get VCR to record events that break"
25
- expect(Docker::Event).to receive(:new_event).exactly(3).times
23
+ let(:container) { Docker::Image.create('fromImage' => 'debian:wheezy').run('bash') }
24
+ it 'receives at least 4 events' do
25
+ expect(Docker::Event)
26
+ .to receive(:new_event)
27
+ .at_least(4).times
26
28
  .and_call_original
27
- fork do
28
- sleep 1
29
- Docker::Image.create('fromImage' => 'debian:wheezy').run('bash')
30
- end
31
- Docker::Event.stream do |event|
32
- puts "#{event}"
33
- if event.status == "die"
34
- break
29
+
30
+ stream_thread = Thread.new do
31
+ Docker::Event.stream do |event|
32
+ puts "#{event}"
35
33
  end
36
34
  end
35
+
36
+ stream_thread.join(0.1)
37
+ container.wait
38
+ stream_thread.join(10)
39
+ stream_thread.kill
40
+
41
+ container.remove
37
42
  end
38
43
  end
39
44
 
40
45
  describe ".since" do
41
- let!(:time) { Time.now.to_i }
46
+ let(:time) { Time.now.to_i + 1 }
47
+ let(:container) { Docker::Image.create('fromImage' => 'debian:wheezy').run('bash') }
42
48
 
43
- it 'receives three events', :vcr do
44
- skip "get VCR to record events that break"
45
- expect(Docker::Event).to receive(:new_event).exactly(3).times
49
+ it 'receives at least 4 events' do
50
+ expect(Docker::Event)
51
+ .to receive(:new_event)
52
+ .at_least(4).times
46
53
  .and_call_original
47
- fork do
48
- sleep 1
49
- Docker::Image.create('fromImage' => 'debian:wheezy').run('bash')
50
- end
51
- Docker::Event.since(time) do |event|
52
- puts "#{event}"
53
- if event.status == "die"
54
- break
54
+
55
+ stream_thread = Thread.new do
56
+ Docker::Event.since(time) do |event|
57
+ puts "#{event}"
55
58
  end
56
59
  end
60
+
61
+ stream_thread.join(0.1)
62
+ container.wait
63
+ stream_thread.join(10)
64
+ stream_thread.kill
65
+
66
+ container.remove
57
67
  end
58
68
  end
59
69
 
@@ -47,7 +47,7 @@ describe Docker::Exec do
47
47
  let(:process) { subject.create(options) }
48
48
  after { container.kill!.remove }
49
49
 
50
- it 'sets the id', :vcr do
50
+ it 'sets the id' do
51
51
  expect(process).to be_a Docker::Exec
52
52
  expect(process.id).to_not be_nil
53
53
  expect(process.connection).to_not be_nil
@@ -83,7 +83,7 @@ describe Docker::Exec do
83
83
  before { subject.start! }
84
84
  after { container.kill!.remove }
85
85
 
86
- it 'returns the description as a Hash', :vcr do
86
+ it 'returns the description as a Hash' do
87
87
  expect(description).to be_a Hash
88
88
  expect(description['ID']).to start_with(subject.id)
89
89
  end
@@ -95,8 +95,7 @@ describe Docker::Exec do
95
95
  described_class.send(:new, Docker.connection, 'id' => rand(10000).to_s)
96
96
  end
97
97
 
98
- it 'raises an error', :vcr do
99
- skip 'The Docker API returns a 200 (docker/docker#9341)'
98
+ it 'raises an error' do
100
99
  expect { subject.start! }.to raise_error(Docker::Error::NotFoundError)
101
100
  end
102
101
  end
@@ -111,12 +110,12 @@ describe Docker::Exec do
111
110
  }
112
111
  after { container.kill!.remove }
113
112
 
114
- it 'returns the stdout and stderr messages', :vcr do
113
+ it 'returns the stdout and stderr messages' do
115
114
  expect(subject.start!).to eq([["hello\n"],[],0])
116
115
  end
117
116
 
118
117
  context 'block is passed' do
119
- it 'attaches to the stream', :vcr do
118
+ it 'attaches to the stream' do
120
119
  chunk = nil
121
120
  result = subject.start! do |stream, c|
122
121
  chunk ||= c
@@ -133,7 +132,7 @@ describe Docker::Exec do
133
132
  }
134
133
  after { container.kill!.remove }
135
134
 
136
- it 'returns empty stdout/stderr messages with exitcode', :vcr do
135
+ it 'returns empty stdout/stderr messages with exitcode' do
137
136
  expect(subject.start!(:detach => true)).to eq([[],[], 0])
138
137
  end
139
138
  end
@@ -144,7 +143,7 @@ describe Docker::Exec do
144
143
  }
145
144
  after { container.kill!.remove }
146
145
 
147
- it 'returns empty stdout and stderr messages with exitcode', :vcr do
146
+ it 'returns empty stdout and stderr messages with exitcode' do
148
147
  expect(subject.start!(:wait => 100)).to eq([[], [], 0])
149
148
  end
150
149
  end
@@ -159,32 +158,18 @@ describe Docker::Exec do
159
158
  }
160
159
  after { container.kill!.remove }
161
160
 
162
- it 'raises an error', :vcr do
163
- pending "VCR doesn't like to record errors"
161
+ it 'raises an error' do
164
162
  expect { subject.start!(:wait => 1) }.to raise_error(Docker::Error::TimeoutError)
165
163
  end
166
164
  end
167
165
 
168
- context 'when the command has already run' do
169
- subject {
170
- described_class.create('Container' => container.id, 'Cmd' => ['date'])
171
- }
172
- before { subject.start! }
173
- after { container.kill!.remove }
174
-
175
- it 'raises an error', :vcr do
176
- skip 'The Docker API returns a 200 (docker/docker#9341)'
177
- expect { subject.start! }.to raise_error(Docker::Error::NotFoundError)
178
- end
179
- end
180
-
181
166
  context 'when the HTTP request returns a 201' do
182
167
  subject {
183
168
  described_class.create('Container' => container.id, 'Cmd' => ['date'])
184
169
  }
185
170
  after { container.kill!.remove }
186
171
 
187
- it 'starts the exec instance', :vcr do
172
+ it 'starts the exec instance' do
188
173
  expect { subject.start! }.not_to raise_error
189
174
  end
190
175
  end
@@ -24,9 +24,10 @@ describe Docker::Image do
24
24
 
25
25
  context 'when no name is given' do
26
26
  let(:id) { subject.id }
27
- subject { described_class.create('fromImage' => 'busybox') }
27
+ subject { described_class.create('fromImage' => 'busybox:latest') }
28
+ after { described_class.create('fromImage' => 'busybox:latest') }
28
29
 
29
- it 'removes the Image', :vcr do
30
+ it 'removes the Image' do
30
31
  subject.remove(:force => true)
31
32
  expect(Docker::Image.all.map(&:id)).to_not include(id)
32
33
  end
@@ -56,7 +57,7 @@ describe Docker::Image do
56
57
  context 'when the local file does not exist' do
57
58
  let(:file) { '/lol/not/a/file' }
58
59
 
59
- it 'raises an error', :vcr do
60
+ it 'raises an error' do
60
61
  expect { new_image }.to raise_error(Docker::Error::ArgumentError)
61
62
  end
62
63
  end
@@ -64,13 +65,13 @@ describe Docker::Image do
64
65
  context 'when the local file does exist' do
65
66
  let(:file) { File.join(project_dir, 'Gemfile') }
66
67
  let(:gemfile) { File.read('Gemfile') }
67
- let(:container) { new_image.run('cat /Gemfile') }
68
+ let(:container) { new_image.run('cat /Gemfile').tap(&:wait) }
68
69
  after do
69
- container.tap(&:wait).remove
70
+ container.remove
70
71
  new_image.remove
71
72
  end
72
73
 
73
- it 'creates a new Image that has that file', :vcr do
74
+ it 'creates a new Image that has that file' do
74
75
  output = container.streaming_logs(stdout: true)
75
76
  expect(output).to eq(gemfile)
76
77
  end
@@ -90,7 +91,7 @@ describe Docker::Image do
90
91
  new_image.remove
91
92
  end
92
93
 
93
- it 'inserts the directory', :vcr do
94
+ it 'inserts the directory' do
94
95
  expect(response.split("\n").sort).to eq(Dir.entries('lib/docker').sort)
95
96
  end
96
97
  end
@@ -103,14 +104,14 @@ describe Docker::Image do
103
104
  let(:license) { File.read('LICENSE') }
104
105
  let(:container) { new_image.run('cat /Gemfile /LICENSE') }
105
106
  let(:response) {
106
- container.streaming_logs(stdout: true)
107
+ container.tap(&:wait).streaming_logs(stdout: true)
107
108
  }
108
109
  after do
109
- container.tap(&:wait).remove
110
+ container.remove
110
111
  new_image.remove
111
112
  end
112
113
 
113
- it 'creates a new Image that has each file', :vcr do
114
+ it 'creates a new Image that has each file' do
114
115
  expect(response).to eq("#{gemfile}#{license}")
115
116
  end
116
117
  end
@@ -120,13 +121,13 @@ describe Docker::Image do
120
121
  let(:file) { File.join(project_dir, 'Gemfile') }
121
122
  after(:each) { new_image.remove }
122
123
 
123
- it 'leave no intermediate containers', :vcr do
124
+ it 'leave no intermediate containers' do
124
125
  expect { new_image }.to change {
125
126
  Docker::Container.all(:all => true).count
126
127
  }.by 0
127
128
  end
128
129
 
129
- it 'creates a new image', :vcr do
130
+ it 'creates a new image' do
130
131
  expect{new_image}.to change{Docker::Image.all.count}.by 1
131
132
  end
132
133
  end
@@ -147,13 +148,13 @@ describe Docker::Image do
147
148
  }
148
149
  after { image.remove(:name => repo_tag, :noprune => true) }
149
150
 
150
- it 'pushes the Image', :vcr do
151
+ it 'pushes the Image' do
151
152
  image.push(credentials)
152
153
  end
153
154
 
154
- it 'streams output from push', :vcr do
155
+ it 'streams output from push' do
155
156
  expect { |b| image.push(credentials, &b) }
156
- .to yield_control
157
+ .to yield_control.at_least(1)
157
158
  end
158
159
 
159
160
  context 'when a tag is specified' do
@@ -167,7 +168,7 @@ describe Docker::Image do
167
168
  }
168
169
 
169
170
  context 'when no tag is specified' do
170
- it 'looks up the first repo tag', :vcr do
171
+ it 'looks up the first repo tag' do
171
172
  expect { image.push }.to_not raise_error
172
173
  end
173
174
  end
@@ -177,7 +178,7 @@ describe Docker::Image do
177
178
  let(:credentials) { nil }
178
179
  let(:repo_tag) { "localhost:5000/true" }
179
180
 
180
- it 'still pushes', :vcr do
181
+ it 'still pushes' do
181
182
  expect { image.push }.to_not raise_error
182
183
  end
183
184
  end
@@ -187,7 +188,7 @@ describe Docker::Image do
187
188
  subject { described_class.create('fromImage' => 'debian:wheezy') }
188
189
  after { subject.remove(:name => 'teh:latest', :noprune => true) }
189
190
 
190
- it 'tags the image with the repo name', :vcr do
191
+ it 'tags the image with the repo name' do
191
192
  subject.tag(:repo => :teh, :force => true)
192
193
  expect(subject.info['RepoTags']).to include 'teh:latest'
193
194
  end
@@ -197,7 +198,7 @@ describe Docker::Image do
197
198
  subject { described_class.create('fromImage' => 'debian:wheezy') }
198
199
  let(:json) { subject.json }
199
200
 
200
- it 'returns additional information about image image', :vcr do
201
+ it 'returns additional information about image image' do
201
202
  expect(json).to be_a Hash
202
203
  expect(json.length).to_not be_zero
203
204
  end
@@ -207,7 +208,7 @@ describe Docker::Image do
207
208
  subject { described_class.create('fromImage' => 'debian:wheezy') }
208
209
  let(:history) { subject.history }
209
210
 
210
- it 'returns the history of the Image', :vcr do
211
+ it 'returns the history of the Image' do
211
212
  expect(history).to be_a Array
212
213
  expect(history.length).to_not be_zero
213
214
  expect(history).to be_all { |elem| elem.is_a? Hash }
@@ -216,32 +217,31 @@ describe Docker::Image do
216
217
 
217
218
  describe '#run' do
218
219
  subject { described_class.create('fromImage' => 'debian:wheezy') }
219
- let(:container) { subject.run(cmd) }
220
+ let(:container) { subject.run(cmd).tap(&:wait) }
220
221
  let(:output) { container.streaming_logs(stdout: true) }
221
222
 
222
- context 'when the argument is a String', :vcr do
223
+ context 'when the argument is a String' do
223
224
  let(:cmd) { 'ls /lib64/' }
224
225
  after { container.remove }
225
226
 
226
227
  it 'splits the String by spaces and creates a new Container' do
227
- container.wait
228
228
  expect(output).to eq("ld-linux-x86-64.so.2\n")
229
229
  end
230
230
  end
231
231
 
232
232
  context 'when the argument is an Array' do
233
233
  let(:cmd) { %w[which pwd] }
234
- after { container.tap(&:wait).remove }
234
+ after { container.remove }
235
235
 
236
- it 'creates a new Container', :vcr do
236
+ it 'creates a new Container' do
237
237
  expect(output).to eq("/bin/pwd\n")
238
238
  end
239
239
  end
240
240
 
241
- context 'when the argument is nil', :vcr do
241
+ context 'when the argument is nil' do
242
242
  let(:cmd) { nil }
243
243
  context 'no command configured in image' do
244
- subject { described_class.create('fromImage' => 'scratch') }
244
+ subject { described_class.create('fromImage' => 'swipely/base') }
245
245
  it 'should raise an error if no command is specified' do
246
246
  expect {container}.to raise_error(Docker::Error::ServerError,
247
247
  "No command specified.")
@@ -253,7 +253,6 @@ describe Docker::Image do
253
253
  after { container.remove }
254
254
 
255
255
  it 'should normally show result if image has Cmd configured' do
256
- container.wait
257
256
  expect(output).to eql "/\n"
258
257
  end
259
258
  end
@@ -263,7 +262,7 @@ describe Docker::Image do
263
262
  describe '#save' do
264
263
  let(:image) { Docker::Image.get('busybox') }
265
264
 
266
- it 'calls the class method', :vcr do
265
+ it 'calls the class method' do
267
266
  expect(Docker::Image).to receive(:save)
268
267
  .with(image.id, 'busybox.tar', anything)
269
268
  image.save('busybox.tar')
@@ -273,7 +272,7 @@ describe Docker::Image do
273
272
  describe '#refresh!' do
274
273
  let(:image) { Docker::Image.create('fromImage' => 'debian:wheezy') }
275
274
 
276
- it 'updates the @info hash', :vcr do
275
+ it 'updates the @info hash' do
277
276
  size = image.info.size
278
277
  image.refresh!
279
278
  expect(image.info.size).to be > size
@@ -285,11 +284,7 @@ describe Docker::Image do
285
284
  Docker::Image.create({'fromImage' => 'debian:wheezy'}, nil, connection)
286
285
  }
287
286
 
288
- it 'updates using the provided connection', :vcr do
289
- expect(connection).to receive(:get)
290
- .with('/images/json', all: true).ordered
291
- expect(connection).to receive(:get)
292
- .with("/images/#{image.id}/json", {}).ordered.and_call_original
287
+ it 'updates using the provided connection' do
293
288
  image.refresh!
294
289
  end
295
290
  end
@@ -299,7 +294,7 @@ describe Docker::Image do
299
294
  subject { described_class }
300
295
 
301
296
  context 'when the Image does not yet exist and the body is a Hash' do
302
- let(:image) { subject.create('fromImage' => 'swipely/scratch') }
297
+ let(:image) { subject.create('fromImage' => 'swipely/base') }
303
298
  let(:creds) {
304
299
  {
305
300
  :username => ENV['DOCKER_API_USER'],
@@ -308,28 +303,33 @@ describe Docker::Image do
308
303
  }
309
304
  }
310
305
 
311
- before { Docker.creds = creds }
312
- after { image.remove(:name => 'swipely/scratch', :noprune => true) }
306
+ before do
307
+ Docker::Image.create('fromImage' => 'swipely/base').remove
308
+ end
309
+ after { Docker::Image.create('fromImage' => 'swipely/base') }
313
310
 
314
- it 'sets the id and sends Docker.creds', :vcr do
311
+ it 'sets the id and sends Docker.creds' do
312
+ allow(Docker).to receive(:creds).and_return(creds)
315
313
  expect(image).to be_a Docker::Image
316
314
  expect(image.id).to match(/\A[a-fA-F0-9]+\Z/)
317
315
  expect(image.id).to_not include('base')
318
316
  expect(image.id).to_not be_nil
319
317
  expect(image.id).to_not be_empty
320
- expect(image.info[:headers].keys).to include 'X-Registry-Auth'
321
318
  end
322
319
  end
323
320
 
324
321
  context 'with a block capturing create output' do
325
322
  let(:create_output) { "" }
326
323
  let(:block) { Proc.new { |chunk| create_output << chunk } }
327
- let!(:image) { subject.create('fromImage' => 'tianon/true', &block) }
328
324
 
329
- before { Docker.creds = nil }
325
+ before do
326
+ Docker.creds = nil
327
+ subject.create('fromImage' => 'tianon/true').remove
328
+ end
330
329
 
331
- it 'calls the block and passes build output', :vcr do
332
- expect(create_output).to match(/Pulling repository tianon\/true/)
330
+ it 'calls the block and passes build output' do
331
+ subject.create('fromImage' => 'tianon/true', &block)
332
+ expect(create_output).to match(/Pulling.*tianon\/true/)
333
333
  end
334
334
  end
335
335
  end
@@ -341,7 +341,7 @@ describe Docker::Image do
341
341
  context 'when the image does exist' do
342
342
  let(:image_name) { 'debian:wheezy' }
343
343
 
344
- it 'returns the new image', :vcr do
344
+ it 'returns the new image' do
345
345
  expect(image).to be_a Docker::Image
346
346
  end
347
347
  end
@@ -359,7 +359,7 @@ describe Docker::Image do
359
359
  Excon.stubs.shift
360
360
  end
361
361
 
362
- it 'raises a not found error', :vcr do
362
+ it 'raises a not found error' do
363
363
  expect { image }.to raise_error(Docker::Error::NotFoundError)
364
364
  end
365
365
  end
@@ -372,16 +372,16 @@ describe Docker::Image do
372
372
  let(:file) { "#{project_dir}/scratch.tar" }
373
373
  after { FileUtils.remove(file) }
374
374
 
375
- it 'exports tarball of image to specified file', :vcr do
376
- Docker::Image.save('scratch', file)
375
+ it 'exports tarball of image to specified file' do
376
+ Docker::Image.save('swipely/base', file)
377
377
  expect(File.exist?(file)).to eq true
378
378
  expect(File.read(file)).to_not be_nil
379
379
  end
380
380
  end
381
381
 
382
382
  context 'when no filename is specified' do
383
- it 'returns raw binary data as string', :vcr do
384
- raw = Docker::Image.save('scratch:latest')
383
+ it 'returns raw binary data as string' do
384
+ raw = Docker::Image.save('swipely/base')
385
385
  expect(raw).to_not be_nil
386
386
  end
387
387
  end
@@ -394,7 +394,7 @@ describe Docker::Image do
394
394
  context 'when the image does exist' do
395
395
  let(:image_name) { 'debian:wheezy' }
396
396
 
397
- it 'returns true', :vcr do
397
+ it 'returns true' do
398
398
  expect(exists).to eq(true)
399
399
  end
400
400
  end
@@ -412,7 +412,7 @@ describe Docker::Image do
412
412
  Excon.stubs.shift
413
413
  end
414
414
 
415
- it 'return false', :vcr do
415
+ it 'return false' do
416
416
  expect(exists).to eq(false)
417
417
  end
418
418
  end
@@ -437,7 +437,7 @@ describe Docker::Image do
437
437
  let(:import) { subject.import(file) }
438
438
  after { import.remove(:noprune => true) }
439
439
 
440
- it 'creates the Image', :vcr do
440
+ it 'creates the Image' do
441
441
  expect(import).to be_a Docker::Image
442
442
  expect(import.id).to_not be_nil
443
443
  end
@@ -445,7 +445,7 @@ describe Docker::Image do
445
445
 
446
446
  context 'when the argument is a URI' do
447
447
  context 'when the URI is invalid' do
448
- it 'raises an error', :vcr do
448
+ it 'raises an error' do
449
449
  expect { subject.import('http://google.com') }
450
450
  .to raise_error(Docker::Error::IOError)
451
451
  end
@@ -456,7 +456,7 @@ describe Docker::Image do
456
456
  let(:import) { subject.import(uri) }
457
457
  after { import.remove(:noprune => true) }
458
458
 
459
- it 'returns an Image', :vcr do
459
+ it 'returns an Image' do
460
460
  expect(import).to be_a Docker::Image
461
461
  expect(import.id).to_not be_nil
462
462
  end
@@ -470,7 +470,7 @@ describe Docker::Image do
470
470
  let(:images) { subject.all(:all => true) }
471
471
  before { subject.create('fromImage' => 'debian:wheezy') }
472
472
 
473
- it 'materializes each Image into a Docker::Image', :vcr do
473
+ it 'materializes each Image into a Docker::Image' do
474
474
  images.each do |image|
475
475
  expect(image).to_not be_nil
476
476
 
@@ -490,7 +490,7 @@ describe Docker::Image do
490
490
  describe '.search' do
491
491
  subject { described_class }
492
492
 
493
- it 'materializes each Image into a Docker::Image', :vcr do
493
+ it 'materializes each Image into a Docker::Image' do
494
494
  expect(subject.search('term' => 'sshd')).to be_all { |image|
495
495
  !image.id.nil? && image.is_a?(described_class)
496
496
  }
@@ -500,7 +500,7 @@ describe Docker::Image do
500
500
  describe '.build' do
501
501
  subject { described_class }
502
502
  context 'with an invalid Dockerfile' do
503
- it 'throws a UnexpectedResponseError', :vcr do
503
+ it 'throws a UnexpectedResponseError' do
504
504
  expect { subject.build('lololol') }
505
505
  .to raise_error(Docker::Error::UnexpectedResponseError)
506
506
  end
@@ -510,7 +510,7 @@ describe Docker::Image do
510
510
  context 'without query parameters' do
511
511
  let(:image) { subject.build("FROM debian:wheezy\n") }
512
512
 
513
- it 'builds an image', :vcr do
513
+ it 'builds an image' do
514
514
  expect(image).to be_a Docker::Image
515
515
  expect(image.id).to_not be_nil
516
516
  expect(image.connection).to be_a Docker::Connection
@@ -526,7 +526,7 @@ describe Docker::Image do
526
526
  }
527
527
  after { image.remove(:noprune => true) }
528
528
 
529
- it 'builds an image and tags it', :vcr do
529
+ it 'builds an image and tags it' do
530
530
  expect(image).to be_a Docker::Image
531
531
  expect(image.id).to_not be_nil
532
532
  expect(image.connection).to be_a Docker::Connection
@@ -542,8 +542,8 @@ describe Docker::Image do
542
542
  let(:block) { Proc.new { |chunk| build_output << chunk } }
543
543
  let!(:image) { subject.build("FROM debian:wheezy\n", &block) }
544
544
 
545
- it 'calls the block and passes build output', :vcr do
546
- expect(build_output).to match(/Step 0 : FROM debian:wheezy/)
545
+ it 'calls the block and passes build output' do
546
+ expect(build_output).to match(/Step \d : FROM debian:wheezy/)
547
547
  end
548
548
  end
549
549
  end
@@ -561,49 +561,42 @@ describe Docker::Image do
561
561
  let(:opts) { {} }
562
562
  let(:block) { Proc.new {} }
563
563
  let(:container) do
564
- Docker::Container.create('Image' => image.id,
565
- 'Cmd' => %w[cat /Dockerfile])
564
+ Docker::Container.create(
565
+ 'Image' => image.id,
566
+ 'Cmd' => %w[cat /Dockerfile]
567
+ ).tap(&:start).tap(&:wait)
566
568
  end
567
569
  let(:output) { container.streaming_logs(stdout: true) }
568
570
 
569
571
  after(:each) do
572
+ container.remove
570
573
  image.remove(:noprune => true)
571
574
  end
572
575
 
573
576
  context 'with no query parameters' do
574
- it 'builds the image', :vcr do
575
- container.tap(&:wait).start
577
+ it 'builds the image' do
576
578
  expect(output).to eq(docker_file.read)
577
579
  end
578
-
579
- after do
580
- container.remove
581
- end
582
580
  end
583
581
 
584
582
  context 'with specifying a repo in the query parameters' do
585
583
  let(:opts) { { "t" => "#{ENV['DOCKER_API_USER']}/debian:from_dir" } }
586
- it 'builds the image and tags it', :vcr do
587
- container.tap(&:wait).start
584
+ it 'builds the image and tags it' do
588
585
  expect(output).to eq(docker_file.read)
589
586
  image.refresh!
590
587
  expect(image.info["RepoTags"]).to eq(
591
588
  ["#{ENV['DOCKER_API_USER']}/debian:from_dir"]
592
589
  )
593
590
  end
594
-
595
- after do
596
- container.remove
597
- end
598
591
  end
599
592
 
600
593
  context 'with a block capturing build output' do
601
594
  let(:build_output) { "" }
602
595
  let(:block) { Proc.new { |chunk| build_output << chunk } }
603
596
 
604
- it 'calls the block and passes build output', :vcr do
597
+ it 'calls the block and passes build output' do
605
598
  image # Create the image variable, which is lazy-loaded by Rspec
606
- expect(build_output).to match(/Step 0 : FROM debian:wheezy/)
599
+ expect(build_output).to match(/Step \d : FROM debian:wheezy/)
607
600
  end
608
601
 
609
602
  context 'uses a cached version the second time' do
@@ -611,9 +604,9 @@ describe Docker::Image do
611
604
  let(:block_two) { Proc.new { |chunk| build_output_two << chunk } }
612
605
  let(:image_two) { subject.build_from_dir(dir, opts, &block_two) }
613
606
 
614
- it 'calls the block and passes build output', :vcr do
607
+ it 'calls the block and passes build output' do
615
608
  image # Create the image variable, which is lazy-loaded by Rspec
616
- expect(build_output).to match(/Step 0 : FROM debian:wheezy/)
609
+ expect(build_output).to match(/Step \d : FROM debian:wheezy/)
617
610
  expect(build_output).to_not match(/Using cache/)
618
611
 
619
612
  image_two # Create the image_two variable, which is lazy-loaded by Rspec
@@ -633,8 +626,9 @@ describe Docker::Image do
633
626
  }
634
627
 
635
628
  before { Docker.creds = creds }
629
+ after { Docker.creds = nil }
636
630
 
637
- it 'sends X-Registry-Config header', :vcr do
631
+ it 'sends X-Registry-Config header' do
638
632
  expect(image.info[:headers].keys).to include('X-Registry-Config')
639
633
  end
640
634
  end