Sha256: ac16ce8b7bbef05648dcee5063dab1510d1e060dd94316d0c0a6bd15450bb2b4

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require "spec_helper"

describe Findable::Configuration do
  let(:storage) { :memory }
  let(:redis) { {host: "localhost", port: 6379, db: 15} }

  describe "#initialize" do
    subject { Findable.config  }

    # defined options
    Findable::Configuration::VALID_OPTIONS.each do |key|
      it { is_expected.to respond_to(key) }
    end

    # default settings
    it { is_expected.to have_attributes(default_storage: :redis) }
    it { is_expected.to have_attributes(redis_options: nil) }
  end

  describe "#merge" do
    subject { Findable.config.merge(default_storage: storage) }

    it { is_expected.to have_attributes(default_storage: storage) }
    it { is_expected.to be_kind_of(Findable::Configuration) }
  end

  describe "#merge!" do
    subject { Findable.config.merge!(default_storage: storage) }

    it { is_expected.to have_attributes(default_storage: storage) }
    it { is_expected.to be_kind_of(Findable::Configuration) }
  end

  describe "Accessible" do
    context "extended" do
      subject { Module.new { extend Findable::Configuration::Accessible } }

      it { is_expected.to respond_to(:configure) }
      it { is_expected.to respond_to(:config) }
    end

    describe "#configure" do
      before do
        Findable.configure do |config|
          config.default_storage = storage
          config.redis_options = redis
        end
      end

      subject { Findable.config }

      it { is_expected.to have_attributes(default_storage: storage) }
      it { is_expected.to have_attributes(redis_options: redis) }

      it {
        expect {
          Findable.configure {|config| config.unknown = :value }
        }.to raise_error
      }
    end

    describe "#config" do
      it { expect(Findable.config.is_a?(Findable::Configuration)).to be_truthy }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
findable-0.0.1 spec/findable/configuration_spec.rb