Sha256: 9edf2f86faaa5d044c34c8e1dc1b1d889e008df0ad210841523f0e28011faea5

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require '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

1 entries across 1 versions & 1 rubygems

Version Path
scoped_search-2.2.1 spec/unit/definition_spec.rb