Sha256: 6a268772fc029ee17aefceb87b6b5c40c8ead417d1a8e8e4dde684ed7f35ab5a

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe User do
  describe 'regexp' do
    it '01' do
      user1 = User.create(:info => "cool")
      user2 = User.create(:info => "hello")

      result = User.regexp(:info, "ll")

      result.should have(1).user
      result.first.should == user2
    
    end
  
    it '02' do
      User.create(:info => "cool")
      User.create(:info => "hello")

      result = User.regexp(:info, "olo")

      result.should have(0).user
    end
  end

  describe 'fuzzy search' do
    it '01' do
      user1 = User.create(:info => "cool")
      user2 = User.create(:info => "hello")

      result = User.fuzzy(User => {:info => "ll"})
      result.should have(1).user
      result.first.should == user2

    end
    
    it '02' do
      User.create(:info => "cool")
      User.create(:info => "hello")

      result = User.fuzzy(User => {:info => "olo"})
      result.should have(0).user

    end

    it '03' do
      User.create(:info => "cool")
      User.create(:info => "hello")

      result = User.fuzzy(User => {:info => "l"})

      User.all.should have(2).user
      result.should have(2).user
    end
    
    it '04' do
      user = User.create(:info => "cool")
      User.create(:info => "hello")
      user.blogs.create(:title => "yeah")

      result = User.includes(:blogs).fuzzy(User => {:info => "lll"}, Blog => {:title => "y"})

      result.should have(1).user
    end




  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
induction_cannon_01-0.0.5 spec/models/base/search_spec.rb
induction_cannon_01-0.0.3 spec/models/base/search_spec.rb
induction_cannon_01-0.0.2 spec/models/user_spec.rb