spec/functional/custom_delimiters_spec.rb in picky-4.17.1 vs spec/functional/custom_delimiters_spec.rb in picky-4.18.0
- old
+ new
@@ -12,30 +12,38 @@
Picky::Query::Token.range_character = '-'
Picky::Query::Token.qualifier_text_delimiter = ':'
Picky::Query::Token.qualifiers_delimiter = ','
end
- it 'offers custom partial delimiters to be set' do
- index = Picky::Index.new :custom_delimiters do
- category :text1
- category :text2
+ context 'offers custom partial delimiters to be set' do
+ let(:index) do
+ index = Picky::Index.new :custom_delimiters do
+ category :text1
+ category :text2
+ end
+
+ index.add Struct.new(:id, :text1, :text2).new(1, 'hello', 'world')
+
+ index
end
-
- index.add Struct.new(:id, :text1, :text2).new(1, 'hello', 'world')
-
- try = Picky::Search.new index
- try.search("hell world").ids.should == []
- try.search("hell* world").ids.should == [1]
- try.search("hello world").ids.should == [1]
+ let(:try) { Picky::Search.new index }
- try.search("hell! world").ids.should == []
- Picky::Query::Token.partial_character = '!'
- try.search("hell! world").ids.should == [1]
+ it { try.search("hell world").ids.should == [] }
+ it { try.search("hell* world").ids.should == [1] }
+ it { try.search("hello world").ids.should == [1] }
- try.search('hell!" world').ids.should == []
- Picky::Query::Token.no_partial_character = '\?'
- try.search('hell!? world').ids.should == []
+ it 'with changed partial character' do
+ try.search("hell! world").ids.should == []
+ Picky::Query::Token.partial_character = '!'
+ try.search("hell! world").ids.should == [1]
+ end
+
+ it 'with changed no-partial character' do
+ try.search('hell!" world').ids.should == []
+ Picky::Query::Token.no_partial_character = '\?'
+ try.search('hell!? world').ids.should == []
+ end
end
it 'offers custom similar delimiters to be set' do
index = Picky::Index.new :custom_delimiters do
category :text1, similarity: Picky::Similarity::Soundex.new
@@ -50,16 +58,18 @@
try.search("hello world").ids.should == [1]
try.search("hell? world").ids.should == []
Picky::Query::Token.similar_character = '\?'
try.search("hell? world").ids.should == [1]
+ Picky::Query::Token.no_similar_character = '!'
+ try.search("hello?! world!").ids.should == [1]
try.search('hell?" world').ids.should == []
- Picky::Query::Token.no_partial_character = '!'
- try.search('hell?! world').ids.should == []
+ Picky::Query::Token.no_partial_character = '\#'
+ try.search('hello?# world#').ids.should == [1]
end
- it 'offers custom similar delimiters to be set' do
+ it 'offers custom qualifiers delimiters to be set' do
index = Picky::Index.new :custom_delimiters do
category :text1, similarity: Picky::Similarity::Soundex.new
category :text2
end