Sha256: 8531603aba00ce349a5f7c1bbf7350d8a6dce1f1650d6ce620c9017bb1f1cf35

Contents?: true

Size: 1.99 KB

Versions: 13

Compression:

Stored size: 1.99 KB

Contents

require 'helper'
require 'flipper/adapters/dual_write'
require 'flipper/adapters/operation_logger'
require 'flipper/spec/shared_adapter_specs'
require 'active_support/notifications'

RSpec.describe Flipper::Adapters::DualWrite do
  let(:local_adapter) do
    Flipper::Adapters::OperationLogger.new Flipper::Adapters::Memory.new
  end
  let(:remote_adapter) do
    Flipper::Adapters::OperationLogger.new Flipper::Adapters::Memory.new
  end
  let(:local) { Flipper.new(local_adapter) }
  let(:remote) { Flipper.new(remote_adapter) }
  let(:sync) { Flipper.new(subject) }

  subject do
    described_class.new(local_adapter, remote_adapter)
  end

  it_should_behave_like 'a flipper adapter'

  it 'only uses local for #features' do
    subject.features
  end

  it 'only uses local for #get' do
    subject.get sync[:search]
  end

  it 'only uses local for #get_multi' do
    subject.get_multi [sync[:search]]
  end

  it 'only uses local for #get_all' do
    subject.get_all
  end

  it 'updates remote and local for #add' do
    subject.add sync[:search]
    expect(remote_adapter.count(:add)).to be(1)
    expect(local_adapter.count(:add)).to be(1)
  end

  it 'updates remote and local for #remove' do
    subject.remove sync[:search]
    expect(remote_adapter.count(:remove)).to be(1)
    expect(local_adapter.count(:remove)).to be(1)
  end

  it 'updates remote and local for #clear' do
    subject.clear sync[:search]
    expect(remote_adapter.count(:clear)).to be(1)
    expect(local_adapter.count(:clear)).to be(1)
  end

  it 'updates remote and local for #enable' do
    feature = sync[:search]
    subject.enable feature, feature.gate(:boolean), local.boolean
    expect(remote_adapter.count(:enable)).to be(1)
    expect(local_adapter.count(:enable)).to be(1)
  end

  it 'updates remote and local for #disable' do
    feature = sync[:search]
    subject.disable feature, feature.gate(:boolean), local.boolean(false)
    expect(remote_adapter.count(:disable)).to be(1)
    expect(local_adapter.count(:disable)).to be(1)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
flipper-0.22.2 spec/flipper/adapters/dual_write_spec.rb
flipper-0.22.1 spec/flipper/adapters/dual_write_spec.rb
flipper-0.22.0 spec/flipper/adapters/dual_write_spec.rb
flipper-0.21.0 spec/flipper/adapters/dual_write_spec.rb
flipper-0.21.0.rc2 spec/flipper/adapters/dual_write_spec.rb
flipper-0.21.0.rc1 spec/flipper/adapters/dual_write_spec.rb
flipper-0.20.4 spec/flipper/adapters/dual_write_spec.rb
flipper-0.20.3 spec/flipper/adapters/dual_write_spec.rb
flipper-0.20.2 spec/flipper/adapters/dual_write_spec.rb
flipper-0.20.1 spec/flipper/adapters/dual_write_spec.rb
flipper-0.20.0 spec/flipper/adapters/dual_write_spec.rb
flipper-0.20.0.beta3 spec/flipper/adapters/dual_write_spec.rb
flipper-0.20.0.beta2 spec/flipper/adapters/dual_write_spec.rb