Sha256: e175ea077992ac39221f658424863c768806d1ea508bb8048bd1bcd4ff8c12e3
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
require 'spec_helper' RSpec.describe Bluekai::Category do describe 'category_id' do let(:bluekai_category_list) do [ { name: 'A', id: 1, parent_id: 0 }, { name: 'B', id: 2, parent_id: 1 }, { name: 'C', id: 3, parent_id: 2 }, { name: 'D', id: 4, parent_id: 2 }, { name: 'E', id: 5, parent_id: 4 } ] end it 'creates, updates and deletes bluekai rules' do expect_any_instance_of(described_class) .to receive(:category_list).and_return(bluekai_category_list) expect(subject.category_id(['A'])).to eq(1) expect(subject.category_id(%w(A B))).to eq(2) expect(subject.category_id(%w(A B C))).to eq(3) expect(subject.category_id(%w(A B D))).to eq(4) expect(subject.category_id(%w(A B D E))).to eq(5) # case insignificance expect(subject.category_id(['a'])).to eq(1) expect(subject.category_id(%w(a b c))).to eq(3) expect(subject.category_id(%w(A b D e))).to eq(5) # nonexistent paths expect(subject.category_id(%w(A B C D))).to be_nil expect(subject.category_id([])).to be_nil expect(subject.category_id(['B'])).to be_nil expect(subject.category_id(%w(B C))).to be_nil expect(subject.category_id(%w(B A))).to be_nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bluekai-0.0.6 | spec/lib/bluekai/category_spec.rb |
bluekai-0.0.5 | spec/lib/bluekai/category_spec.rb |
bluekai-0.0.4 | spec/lib/bluekai/category_spec.rb |