summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-03-02 10:46:23 +0000
committerDouwe Maan <douwe@gitlab.com>2016-03-02 10:46:23 +0000
commit8eadb373ec9e92e0b84a7c37a5866c2ef96b28b1 (patch)
tree7b6ad58eecd3683eb5db23b90009d89823ec0ecd /spec
parent8ec49e47ec7e8181ce4087f4b24008b0d07f7d9e (diff)
parentc9b11322172c97320f6bbddbf6c14b235ab9d7c3 (diff)
downloadgitlab-ce-8eadb373ec9e92e0b84a7c37a5866c2ef96b28b1.tar.gz
Merge branch 'rs-filter-array' into 'master'
Add FilterArray class to Banzai See merge request !3053
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/banzai/filter_array_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter_array_spec.rb b/spec/lib/banzai/filter_array_spec.rb
new file mode 100644
index 00000000000..ea84005e7f8
--- /dev/null
+++ b/spec/lib/banzai/filter_array_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper'
+
+describe Banzai::FilterArray do
+ describe '#insert_after' do
+ it 'inserts an element after a provided element' do
+ filters = described_class.new(%w(a b c))
+
+ filters.insert_after('b', '1')
+
+ expect(filters).to eq %w(a b 1 c)
+ end
+
+ it 'inserts an element at the end when the provided element does not exist' do
+ filters = described_class.new(%w(a b c))
+
+ filters.insert_after('d', '1')
+
+ expect(filters).to eq %w(a b c 1)
+ end
+ end
+
+ describe '#insert_before' do
+ it 'inserts an element before a provided element' do
+ filters = described_class.new(%w(a b c))
+
+ filters.insert_before('b', '1')
+
+ expect(filters).to eq %w(a 1 b c)
+ end
+
+ it 'inserts an element at the beginning when the provided element does not exist' do
+ filters = described_class.new(%w(a b c))
+
+ filters.insert_before('d', '1')
+
+ expect(filters).to eq %w(1 a b c)
+ end
+ end
+end