test/searcher_test.rb in inquisitio-1.4.1 vs test/searcher_test.rb in inquisitio-1.5.0

- old
+ new

@@ -394,13 +394,19 @@ end def test_should_support_options searcher = Searcher.where('Star Wars').options(fields: %w(title^2 plot^0.5)) search_url = searcher.send(:search_url) - assert search_url.include?('q.options=%7Bfields%3A%5B%22title%5E2%22%2C+%22plot%5E0.5%22%5D%7D'), "search url should include q.options parameter:\n#{search_url}" + assert search_url.include?('q.options=%7B%22fields%22%3A%5B%22title%5E2%22%2C%22plot%5E0.5%22%5D%7D'), "search url should include q.options parameter:\n#{search_url}" end + def test_should_support_operator_in_options + searcher = Searcher.where('Star Wars').options(defaultOperator: 'or') + search_url = searcher.send(:search_url) + assert search_url =~ /(\?|&)q.options=%7B%22defaultOperator%22%3A%22or%22%7D(&|$)/, "search url should include q.options parameter:\n#{search_url}" + end + def test_options_doesnt_mutate_searcher searcher = Searcher.where('star wars') searcher.options(fields: %w(title^2.0 plot^0.5)) search_url = searcher.send(:search_url) refute search_url.include?('q.options='), "search url should not include q.options parameter:\n#{search_url}" @@ -429,8 +435,22 @@ def test_should_add_more_than_one_expression_to_search searcher = Searcher.where('star wars').expressions(rank1: 'log10(clicks)*_score', rank2: 'cos( _score)') search_url = searcher.send(:search_url) assert search_url =~ /(\?|&)expr\.rank1=log10%28clicks%29%2A_score(&|$)/, "search url should include expr.rank1 parameter:\n#{search_url}" assert search_url =~ /(\?|&)expr\.rank2=cos%28\+_score%29(&|$)/, "search url should include expr.rank1 parameter:\n#{search_url}" + end + + def test_should_support_structured_parser + Inquisitio.config.api_version = '2013-01-01' + searcher = Searcher.where('star wars').parser(:structured) + search_url = searcher.send(:search_url) + assert search_url =~ /(\?|&)q\.parser=structured(&|$)/, "search url should include q.parser parameter:\n#{search_url}" + end + + def test_should_support_any_parser + Inquisitio.config.api_version = '2013-01-01' + searcher = Searcher.where('star wars').parser(:foo_bar_baz) + search_url = searcher.send(:search_url) + assert search_url =~ /(\?|&)q\.parser=foo_bar_baz(&|$)/, "search url should include q.parser parameter:\n#{search_url}" end end end