Sha256: f6d76e6d31830b4b4b0f1793e52c9004b00165c61178d6dc0de5a53a2e4f848d

Contents?: true

Size: 1.22 KB

Versions: 28

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

class CustomSearch
  def initialize(dbi)
    @dbi = dbi
  end
  def run(query,request=nil)
    @dbi.klass.where(:title => query)
  end
end
describe Lolita::Configuration::Search do
  let(:dbi){Lolita::DBI::Base.create(Post)}

  it "should create search proxy with only dbi" do
    search = Lolita::Configuration::Search.new(dbi)
    search.with.class.to_s.should match(/Lolita::Search::Simple/)
  end

  it "should create search with true argument" do
    search = Lolita::Configuration::Search.new(dbi,true)
    search.with.class.to_s.should match(/Lolita::Search::Simple/)
  end

  it "should accept attributes through hash argument" do
    search = Lolita::Configuration::Search.new(dbi,:with => CustomSearch)
    search.with.class.to_s.should match(/CustomSearch/)
  end

  it "should accept block " do
    search = Lolita::Configuration::Search.new(dbi) do 
      with CustomSearch
    end
    search.with.class.to_s.should match(/CustomSearch/)
  end

  describe "#run" do

    it "should run search on custom class" do
      Fabricate(:post, :title => "my_title")
      search = Lolita::Configuration::Search.new(dbi, :with => CustomSearch)
      search.run("my_title",Object.new).size.should == 1
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
lolita-4.0.11 spec/configuration/search_spec.rb
lolita-4.2.0 spec/configuration/search_spec.rb
lolita-4.0.10 spec/configuration/search_spec.rb
lolita-4.0.9 spec/configuration/search_spec.rb
lolita-4.0.8 spec/configuration/search_spec.rb
lolita-4.0.7 spec/configuration/search_spec.rb
lolita-4.0.6 spec/configuration/search_spec.rb
lolita-4.0.5 spec/configuration/search_spec.rb
lolita-4.0.4 spec/configuration/search_spec.rb
lolita-4.0.3 spec/configuration/search_spec.rb
lolita-4.0.2 spec/configuration/search_spec.rb
lolita-4.0.1 spec/configuration/search_spec.rb
lolita-4.0.0 spec/configuration/search_spec.rb
lolita-3.4.3 spec/configuration/search_spec.rb
lolita-3.4.2 spec/configuration/search_spec.rb
lolita-3.4.1 spec/configuration/search_spec.rb
lolita-3.4.0 spec/configuration/search_spec.rb
lolita-3.3.9 spec/configuration/search_spec.rb
lolita-3.3.8 spec/configuration/search_spec.rb
lolita-3.3.7 spec/configuration/search_spec.rb