Commit 97caed20 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add specs for CI/CD job policy factory method

parent a7a7e2d8
require 'spec_helper'
describe Gitlab::Ci::Build::Policy do
let(:policy) { spy('policy specification') }
before do
stub_const("#{described_class}::Something", policy)
end
describe '.fabricate' do
context 'when policy exists' do
it 'fabricates and initializes relevant policy' do
specs = described_class.fabricate(something: 'some value')
expect(specs).to be_an Array
expect(specs).to be_one
expect(policy).to have_received(:new).with('some value')
end
end
context 'when some policies are not defined' do
it 'gracefully skips unknown policies' do
specs = described_class.fabricate(something: 'first', else: 'unknown')
expect(specs).to be_an Array
expect(specs).to be_one
expect(policy).to have_received(:new).with('first')
end
end
context 'when passing a nil value as specs' do
it 'returns an empty array' do
specs = described_class.fabricate(nil)
expect(specs).to be_an Array
expect(specs).to be_empty
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment