Sha256: b257d029b4db3ca47cf1c1940a2bb012885293a1cc3eddcf57402d379a49078c

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe Sunspot::Rails::Failover do
  describe '.setup' do
    let(:configuration) { double('configuration') }
    
    before do
      Sunspot::Rails.stub(:configuration).and_return(configuration)
      configuration.should_receive(:user_configuration_from_key).with('solr', 'url')
    end
    
    context 'with a master configuration' do
      before do
        configuration.should_receive(:has_master?).and_return(true)
        configuration.should_receive(:user_configuration_from_key).with('master_solr', 'url')
      end
      
      it 'sets the session to master/slave with failover support' do
        described_class.setup
        Sunspot.session.should be_an_instance_of(Sunspot::SessionProxy::MasterSlaveWithFailoverSessionProxy)
      end
    end
    
    context 'with no master configuration' do
      before do
        configuration.should_receive(:has_master?).and_return(false)
      end
          
      it 'sets the session to the default' do
        described_class.setup
        Sunspot.session.should be_an_instance_of(Sunspot::SessionProxy::ThreadLocalSessionProxy)
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sunspot-rails-failover-0.0.3 spec/sunspot-rails-failover_spec.rb