gitlab-org--gitlab-foss/spec/lib/gitlab/ci/build/image_spec.rb

68 lines
1.8 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe Gitlab::Ci::Build::Image do
let(:job) { create(:ci_build, :no_options) }
describe '#from_image' do
subject { described_class.from_image(job) }
context 'when image is defined in job' do
let(:image_name) { 'ruby:2.1' }
let(:job) { create(:ci_build, options: { image: image_name } ) }
2017-03-07 06:30:34 -05:00
it 'fabricates an object of the proper class' do
is_expected.to be_kind_of(described_class)
end
it 'populates fabricated object with the proper name attribute' do
expect(subject.name).to eq(image_name)
end
context 'when image name is empty' do
let(:image_name) { '' }
2017-03-07 06:30:34 -05:00
it 'does not fabricate an object' do
is_expected.to be_nil
end
end
end
context 'when image is not defined in job' do
2017-03-07 06:30:34 -05:00
it 'does not fabricate an object' do
is_expected.to be_nil
end
end
end
describe '#from_services' do
subject { described_class.from_services(job) }
context 'when services are defined in job' do
let(:service_image_name) { 'postgres' }
let(:job) { create(:ci_build, options: { services: [service_image_name] }) }
2017-03-07 06:30:34 -05:00
it 'fabricates an non-empty array of objects' do
is_expected.to be_kind_of(Array)
is_expected.not_to be_empty
expect(subject.first.name).to eq(service_image_name)
end
context 'when service image name is empty' do
let(:service_image_name) { '' }
2017-03-07 06:30:34 -05:00
it 'fabricates an empty array' do
is_expected.to be_kind_of(Array)
is_expected.to be_empty
end
end
end
context 'when services are not defined in job' do
2017-03-07 06:30:34 -05:00
it 'fabricates an empty array' do
is_expected.to be_kind_of(Array)
is_expected.to be_empty
end
end
end
2017-03-06 05:51:09 -05:00
end