Sha256: 56c76e07f3a29a79db44e8f6bc5fb9afd726f9a599b8b93bf73bf48a392f4af4
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
describe Minidusen::Parser do describe '.parse' do describe 'when called with a String' do it 'parses the given string into tokens' do query = Minidusen::Parser.parse('fieldname:fieldvalue word "a phrase"') query.size.should == 3 query[0].field.should == 'fieldname' query[0].value.should == 'fieldvalue' query[1].field.should == 'text' query[1].value.should == 'word' query[2].field.should == 'text' query[2].value.should == 'a phrase' end it 'should parse field tokens first, because they usually give maximum filtering at little cost' do query = Minidusen::Parser.parse('word1 field1:field1-value word2 field2:field2-value') query.collect(&:value).should == ['field1-value', 'field2-value', 'word1', 'word2'] end it 'should not consider the dash to be a word boundary' do query = Minidusen::Parser.parse('Baden-Baden') query.collect(&:value).should == ['Baden-Baden'] end it 'should parse umlauts and accents' do query = Minidusen::Parser.parse('field:åöÙÔøüéíÁ "ÄüÊçñÆ ððÿáÒÉ" pulvérisateur pędzić') query.collect(&:value).should == ['åöÙÔøüéíÁ', 'ÄüÊçñÆ ððÿáÒÉ', 'pulvérisateur', 'pędzić'] end end describe 'when called with a Query' do it 'returns the query' do passed_query = Minidusen::Query.new parsed_query = Minidusen::Parser.parse(passed_query) parsed_query.should == passed_query end end describe 'when called with an array of strings' do it 'returns a query of text tokens' do query = Minidusen::Parser.parse(['word', 'a phrase']) query.size.should == 2 query[0].field.should == 'text' query[0].value.should == 'word' query[1].field.should == 'text' query[1].value.should == 'a phrase' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minidusen-0.8.1 | spec/minidusen/parser_spec.rb |