spec/lib/query/tokens_spec.rb in picky-2.0.0 vs spec/lib/query/tokens_spec.rb in picky-2.1.0

- old
+ new

@@ -5,10 +5,39 @@ before(:all) do Internals::Query::Qualifiers.instance << Internals::Query::Qualifier.new(:specific, [:sp, :spec]) Internals::Query::Qualifiers.instance.prepare end + describe '.processed' do + it 'generates processed tokens from all words' do + expected = [ + Internals::Query::Token.processed('this~'), + Internals::Query::Token.processed('is'), + Internals::Query::Token.processed('a'), + Internals::Query::Token.processed('sp:solr'), + Internals::Query::Token.processed('query"') + ] + + described_class.should_receive(:new).once.with expected + + described_class.processed ['this~', 'is', 'a', 'sp:solr', 'query"'] + end + it 'generates processed tokens from all words' do + expected = [ + Internals::Query::Token.processed('this~', false), + Internals::Query::Token.processed('is', false), + Internals::Query::Token.processed('a', false), + Internals::Query::Token.processed('sp:solr', false), + Internals::Query::Token.processed('query"', false) + ] + + described_class.should_receive(:new).once.with expected + + described_class.processed ['this~', 'is', 'a', 'sp:solr', 'query"'] + end + end + describe 'to_solr_query' do context 'many tokens' do before(:each) do @tokens = described_class.new [ Internals::Query::Token.processed('this~'), @@ -146,9 +175,19 @@ @token3.should_receive(:possible_combinations_in).once.with(:some_index).and_return [:combination31, :combination32, :combination33] @tokens.possible_combinations_in(:some_index).should == [ [:combination11, :combination12], [:combination21], + [:combination31, :combination32, :combination33] + ] + 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 nil + @token3.should_receive(:possible_combinations_in).once.with(:some_index).and_return [:combination31, :combination32, :combination33] + + @tokens.possible_combinations_in(:some_index).should == [ + [:combination11, :combination12], [:combination31, :combination32, :combination33] ] end end \ No newline at end of file