Sha256: 6a4e6f4afbc10a34d37d43a24a02bdc4a41ef4ab4da59ddce6a716fb161b4220

Contents?: true

Size: 1.77 KB

Versions: 13

Compression:

Stored size: 1.77 KB

Contents

require "spec_helper"

describe LaunchDarkly::Config do
  subject { LaunchDarkly::Config }
  describe ".initialize" do
    it "can be initialized with default settings" do
      expect(subject).to receive(:default_capacity).and_return 1234
      expect(subject.new.capacity).to eq 1234
    end
    it "accepts custom arguments" do
      expect(subject).to_not receive(:default_capacity)
      expect(subject.new(capacity: 50).capacity).to eq 50
    end
    it "will chomp base_url and stream_uri" do
      uri = "https://test.launchdarkly.com"
      config = subject.new(base_uri: uri + "/")
      expect(config.base_uri).to eq uri
    end
  end
  describe "@base_uri" do
    it "can be read" do
      expect(subject.new.base_uri).to eq subject.default_base_uri
    end
  end
  describe "@events_uri" do
    it "can be read" do
      expect(subject.new.events_uri).to eq subject.default_events_uri
    end
  end
  describe "@stream_uri" do
    it "can be read" do
      expect(subject.new.stream_uri).to eq subject.default_stream_uri
    end
  end
  describe ".default_cache_store" do
    it "uses Rails cache if it is available" do
      rails = instance_double("Rails", cache: :cache)
      stub_const("Rails", rails)
      expect(subject.default_cache_store).to eq :cache
    end
    it "uses memory store if Rails is not available" do
      expect(subject.default_cache_store).to be_an_instance_of LaunchDarkly::ThreadSafeMemoryStore
    end
  end
  describe ".default_logger" do
    it "uses Rails logger if it is available" do
      rails = instance_double("Rails", logger: :logger)
      stub_const("Rails", rails)
      expect(subject.default_logger).to eq :logger
    end
    it "Uses logger if Rails is not available" do
      expect(subject.default_logger).to be_an_instance_of Logger
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ldclient-rb-2.3.2 spec/config_spec.rb
ldclient-rb-2.3.1 spec/config_spec.rb
ldclient-rb-2.2.7 spec/config_spec.rb
ldclient-rb-2.2.6 spec/config_spec.rb
ldclient-rb-2.2.5 spec/config_spec.rb
ldclient-rb-2.1.5 spec/config_spec.rb
ldclient-rb-2.1.4 spec/config_spec.rb
ldclient-rb-2.1.0 spec/config_spec.rb
ldclient-rb-2.0.6 spec/config_spec.rb
ldclient-rb-2.0.5 spec/config_spec.rb
ldclient-rb-2.0.3 spec/config_spec.rb
ldclient-rb-2.0.2 spec/config_spec.rb
ldclient-rb-2.0.1 spec/config_spec.rb