spec/lib/query/token_spec.rb in picky-2.0.0 vs spec/lib/query/token_spec.rb in picky-2.1.0

- old
+ new

@@ -6,10 +6,19 @@ before(:all) do Internals::Query::Qualifiers.instance << Internals::Query::Qualifier.new(:specific, [:sp, :spec]) Internals::Query::Qualifiers.instance.prepare end + describe '==' do + it 'is equal if the originals are equal' do + described_class.processed('similar~').should == described_class.processed('similar~') + end + it 'is not equal if the originals are not equal' do + described_class.processed('similar~').should_not == described_class.processed('similar') + end + end + describe 'next_similar_token' do before(:each) do @bundle = stub :bundle, :similar => [:array, :of, :similar] @category = stub :category, :bundle_for => @bundle @@ -155,25 +164,34 @@ it_should_qualify '', nil it_should_qualify 'sp:text', :specific end describe 'processed' do + it 'should return a new token' do + described_class.processed('some text').should be_kind_of(described_class) + end + it 'generates a token' do + described_class.processed('some text').class.should == described_class + end + end + + describe 'process' do + let(:token) { described_class.new 'any_text' } + it 'returns itself' do + token.process.should == token + end it 'should have an order' do - token = stub :token - described_class.should_receive(:new).once.and_return token - token.should_receive(:qualify).once.ordered token.should_receive(:extract_original).once.ordered + token.should_receive(:downcase).once.ordered token.should_receive(:partialize).once.ordered token.should_receive(:similarize).once.ordered token.should_receive(:remove_illegals).once.ordered + token.should_receive(:symbolize).once.ordered - described_class.processed :any_text + token.process end - it 'should return a new token' do - described_class.processed('some text').should be_kind_of(described_class) - end end describe 'partial?' do context 'similar, partial' do before(:each) do @@ -351,10 +369,17 @@ context 'partial not nil' do before(:each) do @token = described_class.processed 'text*' end it 'should not set partial' do + @token.instance_variable_set :@partial, false + + @token.partial = true + + @token.instance_variable_get(:@partial).should be_false + end + it 'should not set partial' do @token.partial = false @token.instance_variable_get(:@partial).should be_true end end @@ -380,23 +405,23 @@ describe "processed" do it 'should remove *' do token = described_class.processed 'text*' - token.text.should == 'text' + token.text.should == :text end it 'should remove ~' do token = described_class.processed 'text~' - token.text.should == 'text' + token.text.should == :text end it 'should remove "' do token = described_class.processed 'text"' - token.text.should == 'text' + token.text.should == :text end it "should pass on a processed text" do - described_class.processed('text').text.should == 'text' + described_class.processed('text').text.should == :text end end end \ No newline at end of file