Sha256: e3ccdd4d3cb9b9340a01c59fa1fb63c31fa6f50f13973b3834c7f0ffe6b08681

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 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 || false
        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

1 entries across 1 versions & 1 rubygems

Version Path
benjaminkrause-sunspot_rails-0.10.5 lib/sunspot/spec/extension.rb