spec/lib/query/tokens_spec.rb in picky-3.4.3 vs spec/lib/query/tokens_spec.rb in picky-3.5.0

- old
+ new

@@ -1,24 +1,24 @@ require 'spec_helper' describe Picky::Query::Tokens do - + context 'with ignore_unassigned_tokens true' do it 'generates processed tokens from all words' do expected = [ Picky::Query::Token.processed('this~'), Picky::Query::Token.processed('is'), Picky::Query::Token.processed('a'), Picky::Query::Token.processed('sp:solr'), Picky::Query::Token.processed('query"') ] - + described_class.should_receive(:new).once.with expected, true - + described_class.processed ['this~', 'is', 'a', 'sp:solr', 'query"'], [], true end - + describe 'possible_combinations_in' do before(:each) do @token1 = stub :token1 @token2 = stub :token2 @token3 = stub :token3 @@ -46,40 +46,53 @@ [:combination31, :combination32, :combination33] ] end end end - + describe '.processed' do it 'generates processed tokens from all words' do expected = [ Picky::Query::Token.processed('this~'), Picky::Query::Token.processed('is'), Picky::Query::Token.processed('a'), Picky::Query::Token.processed('sp:solr'), Picky::Query::Token.processed('query"') ] - + described_class.should_receive(:new).once.with expected, false - + described_class.processed ['this~', 'is', 'a', 'sp:solr', 'query"'], [] end it 'generates processed tokens from all words' do expected = [ Picky::Query::Token.processed('this~'), Picky::Query::Token.processed('is'), Picky::Query::Token.processed('a'), Picky::Query::Token.processed('sp:solr'), Picky::Query::Token.processed('query"') ] - + described_class.should_receive(:new).once.with expected, false - + described_class.processed ['this~', 'is', 'a', 'sp:solr', 'query"'], [] end end + describe 'symbolize' do + let(:tokens) { described_class.processed ['a*', 'b'], ['A*', 'B'] } + + it 'has non symbolized tokens' do + tokens.map(&:text).should == ['a', 'b'] + end + it 'symbolizes all tokens' do + tokens.symbolize + + tokens.map(&:text).should == [:a, :b] + end + end + describe 'partialize_last' do context 'special case' do before(:each) do @token = Picky::Query::Token.processed 'a*' @tokens = described_class.new [@token] @@ -138,10 +151,10 @@ describe 'possible_combinations_in' do before(:each) do @token1 = stub :token1 @token2 = stub :token2 @token3 = stub :token3 - + @tokens = described_class.new [@token1, @token2, @token3] end it 'should work correctly' do @token1.should_receive(:possible_combinations_in).once.with(:some_index).and_return [:combination11, :combination12] @token2.should_receive(:possible_combinations_in).once.with(:some_index).and_return [:combination21] \ No newline at end of file