spec/flipper/cloud_spec.rb in flipper-cloud-0.11.0.beta3 vs spec/flipper/cloud_spec.rb in flipper-cloud-0.11.0.beta4

- old
+ new

@@ -1,7 +1,8 @@ require 'helper' require 'flipper/cloud' +require 'flipper/adapters/instrumented' RSpec.describe Flipper::Cloud do context "initialize with token" do let(:token) { 'asdf' } @@ -29,10 +30,14 @@ it 'sets correct token header' do headers = @http_client.instance_variable_get('@headers') expect(headers['Feature-Flipper-Token']).to eq(token) end + + it 'uses noop instrumenter' do + expect(@instance.instrumenter).to be(Flipper::Instrumenters::Noop) + end end context 'initialize with token and options' do before do @instance = described_class.new('asdf', url: 'https://www.fakeflipper.com/sadpanda') @@ -45,7 +50,22 @@ uri = @http_client.instance_variable_get('@uri') expect(uri.scheme).to eq('https') expect(uri.host).to eq('www.fakeflipper.com') expect(uri.path).to eq('/sadpanda') end + end + + it 'can set instrumenter' do + instrumenter = Object.new + instance = described_class.new('asdf', instrumenter: instrumenter) + expect(instance.instrumenter).to be(instrumenter) + end + + it 'allows wrapping adapter with another adapter like the instrumenter' do + adapter_wrapper = lambda do |adapter| + Flipper::Adapters::Instrumented.new(adapter) + end + instance = described_class.new('asdf', adapter_wrapper: adapter_wrapper) + # instance.adapter is memoizable adapter instance + expect(instance.adapter.adapter).to be_instance_of(Flipper::Adapters::Instrumented) end end