Sha256: 2622a479f87e62cb6b22a5a1cf256fac89cfeac08b09101d00b10c51a8c3404a

Contents?: true

Size: 945 Bytes

Versions: 9

Compression:

Stored size: 945 Bytes

Contents

module Sunspot
  module Rails
    module Spec
      module Extension
        def self.included(base)
          base.class_eval do
            class_inheritable_accessor :sunspot_integration
            extend  ClassMethods
          end
        end
        
        def integrate_sunspot?
          self.class.integrate_sunspot?
        end
        
        def mock_sunspot
          [ :index, :remove_from_index ].each do |method_name|
            Sunspot.stub!(method_name)
          end
        end
        
      end
      
      module ClassMethods
        def integrate_sunspot( integrate = true )
          self.sunspot_integration = integrate
        end

        def integrate_sunspot?
          !!self.sunspot_integration
        end
      end
    end
  end
end

module ActiveSupport
  class TestCase
    before(:each) do
      mock_sunspot unless integrate_sunspot?
    end
    
    include Sunspot::Rails::Spec::Extension
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
sunspot_rails-0.11.5 lib/sunspot/spec/extension.rb
sunspot_rails-0.11.4 lib/sunspot/spec/extension.rb
nxa-sunspot_rails-0.11.3 lib/sunspot/spec/extension.rb
sunspot_rails-0.11.3 lib/sunspot/spec/extension.rb
sunspot_rails-0.11.2 lib/sunspot/spec/extension.rb
sunspot_rails-0.11.1 lib/sunspot/spec/extension.rb
sunspot_rails-0.11.0 lib/sunspot/spec/extension.rb
kuahyeow-sunspot_rails-0.10.7 lib/sunspot/spec/extension.rb
kuahyeow-sunspot_rails-0.10.6 lib/sunspot/spec/extension.rb