summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-05-20 17:14:22 -0500
committerDouwe Maan <douwe@selenight.nl>2016-05-20 17:14:22 -0500
commitec86644545c1c2567dfaacb6d53d150a5dfa28d6 (patch)
tree1446dee382b4bb3fc80e2021041268c19ce751d8 /spec/lib
parentbaccd1838c92a0d38d3f38b93e9911c97adfef21 (diff)
parentab96ca2bf1ae72817ff5cedf1792c8f7563ebdef (diff)
downloadgitlab-ce-ec86644545c1c2567dfaacb6d53d150a5dfa28d6.tar.gz
Merge branch 'zj-gitignore-dropdown'
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/gitignore_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/lib/gitlab/gitignore_spec.rb b/spec/lib/gitlab/gitignore_spec.rb
new file mode 100644
index 00000000000..72baa516cc4
--- /dev/null
+++ b/spec/lib/gitlab/gitignore_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe Gitlab::Gitignore do
+ subject { Gitlab::Gitignore }
+
+ 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')
+
+ expect(ruby).to be_a Gitlab::Gitignore
+ expect(ruby.name).to eq('Ruby')
+ end
+ end
+
+ describe '#content' do
+ it 'loads the full file' do
+ gitignore = subject.new(Rails.root.join('vendor/gitignore/Ruby.gitignore'))
+
+ expect(gitignore.name).to eq 'Ruby'
+ expect(gitignore.content).to start_with('*.gem')
+ end
+ end
+end