BigW Consortium Gitlab

gitignore_template_spec.rb 985 Bytes
Newer Older
1 2
require 'spec_helper'

3
describe Gitlab::Template::GitignoreTemplate do
4
  subject { described_class }
5

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
  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')

27
      expect(ruby).to be_a described_class
28
      expect(ruby.name).to eq('Ruby')
29 30 31 32 33
    end
  end

  describe '#content' do
    it 'loads the full file' do
34
      gitignore = subject.new(Rails.root.join('vendor/gitignore/Ruby.gitignore'))
35 36 37 38 39 40

      expect(gitignore.name).to eq 'Ruby'
      expect(gitignore.content).to start_with('*.gem')
    end
  end
end