spec/lib/application_spec.rb in picky-0.9.4 vs spec/lib/application_spec.rb in picky-0.10.0

- old
+ new

@@ -5,33 +5,50 @@ describe Application do describe "integration" do it "should run ok" do lambda { + class MinimalTestApplication < Application + books = index :books, + Sources::DB.new('SELECT id, title FROM books', :file => 'app/db.yml'), + category(:title) + + + full = Query::Full.new books + live = Query::Live.new books + + route %r{^/books/full} => full + route %r{^/books/live} => live + end + Tokenizers::Index.default.tokenize 'some text' + Tokenizers::Query.default.tokenize 'some text' + }.should_not raise_error + end + it "should run ok" do + lambda { # TODO Add all possible cases. # class TestApplication < Application - indexing.removes_characters(/[^a-zA-Z0-9\s\/\-\"\&\.]/) - indexing.contracts_expressions(/mr\.\s*|mister\s*/i, 'mr ') - indexing.stopwords(/\b(and|the|of|it|in|for)\b/) - indexing.splits_text_on(/[\s\/\-\"\&\.]/) - indexing.removes_characters_after_splitting(/[\.]/) + default_indexing removes_characters: /[^a-zA-Z0-9\s\/\-\"\&\.]/, + contracts_expressions: [/mr\.\s*|mister\s*/i, 'mr '], + stopwords: /\b(and|the|of|it|in|for)\b/, + splits_text_on: /[\s\/\-\"\&\.]/, + removes_characters_after_splitting: /[\.]/ + + default_querying removes_characters: /[^a-zA-Z0-9äöü\s\/\-\,\&\"\~\*\:]/, + stopwords: /\b(and|the|of|it|in|for)\b/, + splits_text_on: /[\s\/\-\,\&]+/, + normalizes_words: [[/Deoxyribonucleic Acid/i, 'DNA']], + + substitutes_characters_with: CharacterSubstitution::European.new, + maximum_tokens: 5 - books_index = index Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml'), - field(:title, :similarity => Similarity::DoubleLevenshtone.new(3)), # Up to three similar title word indexed. - field(:author), - field(:isbn, :partial => Partial::None.new) # Partially searching on an ISBN makes not much sense. + books_index = index :books, + Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml'), + category(:title, :similarity => Similarity::DoubleLevenshtone.new(3)), # Up to three similar title word indexed. + category(:author), + category(:isbn, :partial => Partial::None.new) # Partially searching on an ISBN makes not much sense. - # Note that Picky needs the following characters to - # pass through, as they are control characters: *"~: - # - querying.removes_characters(/[^a-zA-Z0-9äöü\s\/\-\,\&\"\~\*\:]/) - querying.stopwords(/\b(and|the|of|it|in|for)\b/) - querying.splits_text_on(/[\s\/\-\,\&]+/) - querying.normalizes_words([ - [/Deoxyribonucleic Acid/i, 'DNA'] - ]) - querying.maximum_tokens 5 full = Query::Full.new books_index live = Query::Live.new books_index route %r{^/books/full} => full \ No newline at end of file