spec/thinking_sphinx/search/query_spec.rb in thinking-sphinx-3.0.1 vs spec/thinking_sphinx/search/query_spec.rb in thinking-sphinx-3.0.2

- old
+ new

@@ -1,9 +1,10 @@ module ThinkingSphinx class Search; end end +require 'active_support/core_ext/object/blank' require './lib/thinking_sphinx/search/query' describe ThinkingSphinx::Search::Query do describe '#to_s' do it "passes through the keyword as provided" do @@ -39,8 +40,27 @@ it "does not star the sphinx_internal_class field keyword" do query = ThinkingSphinx::Search::Query.new '', {:sphinx_internal_class => 'article'}, true query.to_s.should == '@sphinx_internal_class article' + end + + it "handles null values by removing them from the conditions hash" do + query = ThinkingSphinx::Search::Query.new '', :title => nil + + query.to_s.should == '' + end + + it "handles empty string values by removing them from the conditions hash" do + query = ThinkingSphinx::Search::Query.new '', :title => '' + + query.to_s.should == '' + end + + it "allows mixing of blank and non-blank conditions" do + query = ThinkingSphinx::Search::Query.new 'tasty', :title => 'pancakes', + :ingredients => nil + + query.to_s.should == 'tasty @title pancakes' end end end