Sha256: 834e101a78ab90b53c85423d67169c38f7c5a2da2c30fe5ca9b3929451fca857

Contents?: true

Size: 800 Bytes

Versions: 2

Compression:

Stored size: 800 Bytes

Contents

require 'spec_helper'

describe Dusen::ActiveRecord::SearchText do

  describe '.match' do

    it 'should find records for the given list of words' do
      match = User::WithFulltext.create!(:name => 'Abraham', :city => 'Fooville')
      no_match = User::WithFulltext.create!(:name => 'Elizabeth', :city => 'Fooville')
      matches = Dusen::ActiveRecord::SearchText.match(User::WithFulltext, ['Abraham', 'Fooville'])
      matches.all.should == [match]
    end

    it 'should find records by only giving the prefix of a word' do
      match = User::WithFulltext.create!(:name => 'Abraham')
      no_match = User::WithFulltext.create!(:name => 'Elizabeth')
      matches = Dusen::ActiveRecord::SearchText.match(User::WithFulltext, ['Abra'])
      matches.all.should == [match]
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dusen-0.4.0 spec/shared/spec/dusen/active_record/search_text_spec.rb
dusen-0.3.0 spec/shared/spec/dusen/active_record/search_text_spec.rb