Sha256: c5390c287be23394e40fb25a3f62efcf7f9b2bd74976e8c7c3c0a4c256cbf5b1

Contents?: true

Size: 1.92 KB

Versions: 8

Compression:

Stored size: 1.92 KB

Contents

require 'spec_helper'

describe Waistband::Configuration do

  let(:config) { Waistband.config }

  it "loads config yml" do
    expect(config.timeout).to eql 2
  end

  it "loads indexes config" do
    expect(config.index('search')).to be_a Hash
    expect(config.index('search')['settings']['index']['number_of_shards']).to eql 1
  end

  it "loads multiple indexes config" do
    expect(config.index('events')).to be_a Hash
    expect(config.index('events')['settings']['index']['number_of_shards']).to eql 1
  end

  it "proxies the client" do
    expect(::Waistband.config.client).to be_a ::Elasticsearch::Transport::Client
    expect(::Waistband.client).to be_a ::Elasticsearch::Transport::Client
  end

  it "permits passing in an adapter to use to the client" do
    original_config = YAML.load_file(File.join(::Waistband.config.config_dir, 'waistband.yml'))['test']

    expect(::Waistband.config.instance_variable_get('@adapter')).to be_nil

    expect(YAML).to receive(:load).and_return({'test' => original_config.merge({'adapter' => :net_http})}).at_least(:once)
    ::Waistband.config.setup
    expect(::Waistband.config.instance_variable_get('@adapter')).to eql :net_http
    expect(::Waistband.client.transport.options[:adapter]).to eql :net_http
  end

  it "permits changing the timeout on command" do
    expect(::Waistband.config.send(:timeout)).to eql 2
    ::Waistband.config.timeout = 10
    expect(::Waistband.config.send(:timeout)).to eql 10
    ::Waistband.config.reset_timeout
    expect(::Waistband.config.send(:timeout)).to eql 2
  end

  describe '#hosts' do

    it "returns array of all available servers' configs" do
      expect(config.hosts).to be_an Array
      expect(config.hosts.size).to eql 2

      config.hosts.each_with_index do |server, i|
        expect(server['host']).to match /127\.0\.0\.1|localhost/
        expect(server['port']).to eql 9200
        expect(server['protocol']).to eql 'http'
      end
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
waistband-0.14.3 spec/lib/configuration_spec.rb
waistband-0.14.2 spec/lib/configuration_spec.rb
waistband-0.14.1 spec/lib/configuration_spec.rb
waistband-0.14.0 spec/lib/configuration_spec.rb
waistband-0.13.0 spec/lib/configuration_spec.rb
waistband-0.12.2 spec/lib/configuration_spec.rb
waistband-0.12.1 spec/lib/configuration_spec.rb
waistband-0.11.3 spec/lib/configuration_spec.rb