Sha256: 57bd37b1228b9366c0ac89c90ed767467f0aaa952dc89275cc932528a84d1de8

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

require 'spec/spec_helper'

describe "ThinkingSphinx::ActiveRecord::Search" do
  it "should add search_for_ids to ActiveRecord::Base" do
    ActiveRecord::Base.methods.should include("search_for_ids")
  end
  
  it "should add search_for_ids to ActiveRecord::Base" do
    ActiveRecord::Base.methods.should include("search")
  end
  
  describe "search_for_ids method" do
    before :each do
      ThinkingSphinx::Search.stub_method(:search_for_ids => true)
    end
    
    after :each do
      ThinkingSphinx::Search.unstub_method(:search_for_ids)
    end
    
    it "should call ThinkingSphinx::Search#search_for_ids with the class option set" do
      Person.search_for_ids("search")
      
      ThinkingSphinx::Search.should have_received(:search_for_ids).with(
        "search", :class => Person
      )
    end
    
    it "should override the class option" do
      Person.search_for_ids("search", :class => Friendship)
      
      ThinkingSphinx::Search.should have_received(:search_for_ids).with(
        "search", :class => Person
      )
    end
  end
  
  describe "search method" do
    before :each do
      ThinkingSphinx::Search.stub_method(:search => true)
    end
    
    after :each do
      ThinkingSphinx::Search.unstub_method(:search)
    end
    
    it "should call ThinkingSphinx::Search#search with the class option set" do
      Person.search("search")
      
      ThinkingSphinx::Search.should have_received(:search).with(
        "search", :class => Person
      )
    end
    
    it "should override the class option" do
      Person.search("search", :class => Friendship)
      
      ThinkingSphinx::Search.should have_received(:search).with(
        "search", :class => Person
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
freelancing-god-thinking-sphinx-0.9.7 spec/unit/thinking_sphinx/active_record/search_spec.rb