spec/kontena/cli/app/docker_helper_spec.rb in kontena-cli-0.16.0.pre7 vs spec/kontena/cli/app/docker_helper_spec.rb in kontena-cli-0.16.0.pre8
- old
+ new
@@ -44,10 +44,15 @@
'image' => 'test_service',
}
}
end
+ before :each do
+ # image does not exist
+ allow(subject).to receive(:image_exist?).with('test_service').and_return(false)
+ end
+
describe '#validate_image_name' do
context 'when image name is valid' do
it 'returns true' do
expect(subject.validate_image_name('registry.kontena.local/image-name:latest')).to be_truthy
expect(subject.validate_image_name('my-registry.com/organization/image_name:latest')).to be_truthy
@@ -107,30 +112,30 @@
it 'builds image' do
service = {
'build' => { 'context' => '.' },
'image' => 'test_service'
}
- expect(subject).to receive(:system).with("docker build -t test_service ."). and_return(true)
+ expect(subject).to receive(:system).with('docker', 'build', '-t', 'test_service', '.'). and_return(true)
subject.build_docker_image(service)
end
it 'builds image with no-cache' do
service = {
'build' => { 'context' => '.' },
'image' => 'test_service'
}
- expect(subject).to receive(:system).with("docker build -t test_service --no-cache ."). and_return(true)
+ expect(subject).to receive(:system).with('docker', 'build', '-t', 'test_service', '--no-cache', '.'). and_return(true)
subject.build_docker_image(service, true)
end
it 'builds image with alternate dockerfile' do
service = {
'build' => { 'context' => '.', 'dockerfile' => 'other_dockerfile' },
'image' => 'test_service'
}
expected_path = File.join(File.expand_path('.'), 'other_dockerfile')
- expect(subject).to receive(:system).with("docker build -t test_service -f #{expected_path} ."). and_return(true)
+ expect(subject).to receive(:system).with('docker', 'build', '-t', 'test_service', '-f', expected_path, '.'). and_return(true)
subject.build_docker_image(service)
end
it 'builds image' do
service = {
@@ -141,10 +146,10 @@
'BAR' => 'foo'
}
},
'image' => 'test_service'
}
- expect(subject).to receive(:system).with("docker build -t test_service --build-arg FOO=bar --build-arg BAR=foo ."). and_return(true)
+ expect(subject).to receive(:system).with('docker', 'build', '-t', 'test_service', '--build-arg=FOO=bar', '--build-arg=BAR=foo', '.'). and_return(true)
subject.build_docker_image(service)
end
end
end