Sha256: 1594074e748a33ba173bcdf9fd1b75f744b3e7ee806707c7f82e8620ee1d2f47

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

require "#{File.dirname(__FILE__)}/../spec_helper"

describe ScopedSearch::Definition do

  before(:each) do
    @klass      = mock_activerecord_class
    @definition = ScopedSearch::Definition.new(@klass)
    @definition.stub!(:setup_adapter)
  end


  describe '#initialize' do

    if ActiveRecord::VERSION::MAJOR == 2
      
      it "should create the named scope when" do
        @klass.should_receive(:named_scope).with(:search_for, instance_of(Proc))
        ScopedSearch::Definition.new(@klass)
      end

      it "should not create the named scope if it already exists" do
        @klass.stub!(:search_for)
        @klass.should_not_receive(:named_scope)
        ScopedSearch::Definition.new(@klass)
      end
      
    elsif ActiveRecord::VERSION::MAJOR == 3
      
      it "should create the named scope when" do
        @klass.should_receive(:scope).with(:search_for, instance_of(Proc))
        ScopedSearch::Definition.new(@klass)
      end

      it "should not create the named scope if it already exists" do
        @klass.stub!(:search_for)
        @klass.should_not_receive(:scope)
        ScopedSearch::Definition.new(@klass)
      end
      
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
scoped_search-2.3.7 spec/unit/definition_spec.rb
scoped_search-2.3.6 spec/unit/definition_spec.rb
scoped_search-2.3.5 spec/unit/definition_spec.rb
scoped_search-2.3.4 spec/unit/definition_spec.rb
scoped_search-2.3.3 spec/unit/definition_spec.rb
scoped_search-2.3.1 spec/unit/definition_spec.rb
scoped_search-2.3.0 spec/unit/definition_spec.rb
scoped_search-2.2.0 spec/unit/definition_spec.rb