spec/lib/query/token_spec.rb in picky-4.10.0 vs spec/lib/query/token_spec.rb in picky-4.11.0

- old
+ new

@@ -12,61 +12,64 @@ end end describe 'categorize' do let(:mapper) do - categories = Picky::Index.new :categories - @category1 = categories.category :category1 - @category2 = categories.category :category2 - @category3 = categories.category :category3 - Picky::Query::QualifierCategoryMapper.new [categories] + # TODO Can we remove the index? + # + index = Picky::Index.new :mapper + categories = Picky::Categories.new + @category1 = categories << Picky::Category.new(:category1, index) + @category2 = categories << Picky::Category.new(:category2, index) + @category3 = categories << Picky::Category.new(:category3, index) + Picky::QualifierMapper.new categories end context 'with qualifiers' do let(:token) { described_class.processed 'category1:qualifier', 'category1:Qualifier' } context 'unrestricted' do it 'categorizes correctly' do - token.categorize(mapper).should == [@category1] + token.predefined_categories(mapper).should == [@category1] end end context 'restricted' do before(:each) do mapper.restrict_to :category1 end it 'categorizes correctly' do - token.categorize(mapper).should == [@category1] + token.predefined_categories(mapper).should == [@category1] end end context 'restricted' do before(:each) do mapper.restrict_to :category2, :category3 end it 'categorizes correctly' do - token.categorize(mapper).should == [] + token.predefined_categories(mapper).should == [] end end end context 'without qualifiers' do let(:token) { described_class.processed 'noqualifier', 'NoQualifier' } context 'unrestricted' do it 'categorizes correctly' do - token.categorize(mapper).should == nil + token.predefined_categories(mapper).should == nil end end context 'restricted' do before(:each) do mapper.restrict_to :category1 end it 'categorizes correctly' do - token.categorize(mapper).should == [@category1] + token.predefined_categories(mapper).should == [@category1] end end context 'restricted' do before(:each) do mapper.restrict_to :category2, :category3 end it 'categorizes correctly' do - token.categorize(mapper).should == [@category2, @category3] + token.predefined_categories(mapper).should == [@category2, @category3] end end end end @@ -92,10 +95,12 @@ end it 'returns a list of tokens with the right original' do token.similar_tokens_for(@category).map(&:original).should == ['array', 'of', 'similar'] end it 'returns a list of tokens with the right categorization' do - token.similar_tokens_for(@category).map(&:predefined_categories).should == [[@category], [@category], [@category]] + token.similar_tokens_for(@category).map do |token| + token.predefined_categories nil # TODO Clean this up. + end.should == [[@category], [@category], [@category]] end end context 'without similar' do before(:each) do @bundle = stub :bundle, :similar => [] \ No newline at end of file