2b48da22ca
* master: (285 commits) Bump recaptcha gem to 3.0.0 to remove deprecated stoken support Load knapsack in Rakefile only when is bundled Add License Finder information to contribution acceptance criteria. Add LGPLv2 to license whiltelist Instrument `RepositoryCheck::SingleRepositoryWorker` manually Bump nokogiri to 1.6.8 Fix alignment of wiki top area Update charcoal theme colors Update nav link font size and spacing; fix hamburger icon Fix control btn position Remove todos count tests in nav Test impersonation using img data attribute instead of username Implement compact side nav Fix knapsack for master Align links and tabs Add scrolling tabs to code subnav Finish styling sub nav Updated colors Fixed failing tests CHANGELOG item ... Conflicts: lib/gitlab/ci/config.rb spec/lib/gitlab/ci/config_spec.rb
73 lines
1.5 KiB
Ruby
73 lines
1.5 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Gitlab::Ci::Config do
|
|
let(:config) do
|
|
described_class.new(yml)
|
|
end
|
|
|
|
context 'when config is valid' do
|
|
let(:yml) do
|
|
<<-EOS
|
|
image: ruby:2.2
|
|
|
|
rspec:
|
|
script:
|
|
- gem install rspec
|
|
- rspec
|
|
EOS
|
|
end
|
|
|
|
describe '#to_hash' do
|
|
it 'returns hash created from string' do
|
|
hash = {
|
|
image: 'ruby:2.2',
|
|
rspec: {
|
|
script: ['gem install rspec',
|
|
'rspec']
|
|
}
|
|
}
|
|
|
|
expect(config.to_hash).to eq hash
|
|
end
|
|
|
|
describe '#valid?' do
|
|
it 'is valid' do
|
|
expect(config).to be_valid
|
|
end
|
|
|
|
it 'has no errors' do
|
|
expect(config.errors).to be_empty
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when config is invalid' do
|
|
context 'when yml is incorrect' do
|
|
let(:yml) { '// invalid' }
|
|
|
|
describe '.new' do
|
|
it 'raises error' do
|
|
expect { config }.to raise_error(
|
|
Gitlab::Ci::Config::Loader::FormatError,
|
|
/Invalid configuration format/
|
|
)
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when config logic is incorrect' do
|
|
let(:yml) { 'before_script: "ls"' }
|
|
|
|
describe '#valid?' do
|
|
it 'is not valid' do
|
|
expect(config).not_to be_valid
|
|
end
|
|
|
|
it 'has errors' do
|
|
expect(config.errors).not_to be_empty
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|