diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-03-02 10:46:23 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-03-02 10:46:23 +0000 |
commit | 8eadb373ec9e92e0b84a7c37a5866c2ef96b28b1 (patch) | |
tree | 7b6ad58eecd3683eb5db23b90009d89823ec0ecd /spec | |
parent | 8ec49e47ec7e8181ce4087f4b24008b0d07f7d9e (diff) | |
parent | c9b11322172c97320f6bbddbf6c14b235ab9d7c3 (diff) | |
download | gitlab-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.rb | 39 |
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 |