Sha256: 821d157724307020936fbc7a717a09d1a9c507c9368aa1bbca0e918e57ea4547

Contents?: true

Size: 1.81 KB

Versions: 7

Compression:

Stored size: 1.81 KB

Contents

require 'helper'
require 'flipper/cloud/configuration'
require 'flipper/adapters/instrumented'

RSpec.describe Flipper::Cloud::Configuration do
  let(:required_options) do
    { token: "asdf" }
  end

  it "can set token" do
    instance = described_class.new(required_options)
    expect(instance.token).to eq(required_options[:token])
  end

  it "can set instrumenter" do
    instrumenter = Object.new
    instance = described_class.new(required_options.merge(instrumenter: instrumenter))
    expect(instance.instrumenter).to be(instrumenter)
  end

  it "can set read_timeout" do
    instance = described_class.new(required_options.merge(read_timeout: 5))
    expect(instance.read_timeout).to eq(5)
  end

  it "can set open_timeout" do
    instance = described_class.new(required_options.merge(open_timeout: 5))
    expect(instance.open_timeout).to eq(5)
  end

  it "can set debug_output" do
    instance = described_class.new(required_options.merge(debug_output: STDOUT))
    expect(instance.debug_output).to eq(STDOUT)
  end

  it "defaults adapter block" do
    instance = described_class.new(required_options)
    expect(instance.adapter).to be_instance_of(Flipper::Adapters::Http)
  end

  it "can override adapter block" do
    instance = described_class.new(required_options)
    instance.adapter do |adapter|
      Flipper::Adapters::Instrumented.new(adapter)
    end
    expect(instance.adapter).to be_instance_of(Flipper::Adapters::Instrumented)
  end

  it "can override url" do
    options = required_options.merge(url: "http://localhost:5000/adapter")
    instance = described_class.new(options)
    expect(instance.url).to eq("http://localhost:5000/adapter")

    instance = described_class.new(required_options)
    instance.url = "http://localhost:5000/adapter"
    expect(instance.url).to eq("http://localhost:5000/adapter")
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
flipper-cloud-0.12.2 spec/flipper/cloud/configuration_spec.rb
flipper-cloud-0.12.1 spec/flipper/cloud/configuration_spec.rb
flipper-cloud-0.12.0 spec/flipper/cloud/configuration_spec.rb
flipper-cloud-0.11.0 spec/flipper/cloud/configuration_spec.rb
flipper-cloud-0.11.0.rc1 spec/flipper/cloud/configuration_spec.rb
flipper-cloud-0.11.0.beta9 spec/flipper/cloud/configuration_spec.rb
flipper-cloud-0.11.0.beta8 spec/flipper/cloud/configuration_spec.rb