Sha256: 6570063a06783c1bfda67369c5b0ee4aeb58ab7c36ea0aa3ab6607a4a4bfbe6c
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require "spec_helper" describe ScopedSearch::QueryBuilder do before(:each) do @definition = double('ScopedSearch::Definition') @definition.stub(:klass).and_return(Class.new(ActiveRecord::Base)) @definition.stub(:profile).and_return(:default) @definition.stub(:default_order).and_return(nil) @definition.stub(:profile=).and_return(true) @definition.klass.stub(:connection).and_return(double()) end it "should raise an ArgumentError if the query is not set" do lambda { ScopedSearch::QueryBuilder.build_query(@definition, nil) }.should raise_error(ArgumentError) end it "should return empty conditions if the query is blank" do ScopedSearch::QueryBuilder.build_query(@definition, "").should == { } end it "should return empty conditions if the query is whitespace only" do ScopedSearch::QueryBuilder.build_query(@definition, "\t ").should == { } end it "should use default adapter when connection type is unknown" do ScopedSearch::QueryBuilder.class_for(@definition).should == ScopedSearch::QueryBuilder end it "should use postgres adapter for postgres-like connection" do connection = double() connection.stub("name").and_return("SomePostgreSQLAdapter") @definition.klass.connection.stub("class").and_return(connection) ScopedSearch::QueryBuilder.class_for(@definition).should == ScopedSearch::QueryBuilder::PostgreSQLAdapter end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scoped_search-3.3.0 | spec/unit/query_builder_spec.rb |