2017-05-08 23:50:23 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
describe BlobViewer::GitlabCiYml do
|
2017-05-08 23:50:23 +00:00
|
|
|
include FakeBlobHelpers
|
|
|
|
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { build_stubbed(:project) }
|
2017-05-08 23:50:23 +00:00
|
|
|
let(:data) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
|
|
|
|
let(:blob) { fake_blob(path: '.gitlab-ci.yml', data: data) }
|
|
|
|
subject { described_class.new(blob) }
|
|
|
|
|
|
|
|
describe '#validation_message' do
|
|
|
|
it 'calls prepare! on the viewer' do
|
|
|
|
expect(subject).to receive(:prepare!)
|
|
|
|
|
|
|
|
subject.validation_message
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the configuration is valid' do
|
|
|
|
it 'returns nil' do
|
|
|
|
expect(subject.validation_message).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the configuration is invalid' do
|
|
|
|
let(:data) { 'oof' }
|
|
|
|
|
|
|
|
it 'returns the error message' do
|
|
|
|
expect(subject.validation_message).to eq('Invalid configuration format')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|