2019-08-22 06:57:44 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-29 10:25:03 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-06-24 15:43:46 -04:00
|
|
|
describe Gitlab::Template::GitignoreTemplate do
|
2016-05-27 05:00:56 -04:00
|
|
|
subject { described_class }
|
2016-05-12 07:27:25 -04:00
|
|
|
|
2016-04-29 10:25:03 -04:00
|
|
|
describe '.all' do
|
|
|
|
it 'strips the gitignore suffix' do
|
|
|
|
expect(subject.all.first.name).not_to end_with('.gitignore')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'combines the globals and rest' do
|
|
|
|
all = subject.all.map(&:name)
|
|
|
|
|
|
|
|
expect(all).to include('Vim')
|
|
|
|
expect(all).to include('Ruby')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.find' do
|
|
|
|
it 'returns nil if the file does not exist' do
|
|
|
|
expect(subject.find('mepmep-yadida')).to be nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the Gitignore object of a valid file' do
|
|
|
|
ruby = subject.find('Ruby')
|
|
|
|
|
2017-05-01 11:13:33 -04:00
|
|
|
expect(ruby).to be_a described_class
|
2016-05-12 07:27:25 -04:00
|
|
|
expect(ruby.name).to eq('Ruby')
|
2016-04-29 10:25:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#content' do
|
|
|
|
it 'loads the full file' do
|
2016-05-12 07:27:25 -04:00
|
|
|
gitignore = subject.new(Rails.root.join('vendor/gitignore/Ruby.gitignore'))
|
2016-04-29 10:25:03 -04:00
|
|
|
|
|
|
|
expect(gitignore.name).to eq 'Ruby'
|
|
|
|
expect(gitignore.content).to start_with('*.gem')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|