Sha256: 3aef025619c60dc0e992c89ba03d596b91885cf34cf836c740599403f212ce31

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

require 'flipper/adapters/mongo'

Mongo::Logger.logger.level = Logger::INFO

RSpec.describe Flipper::Adapters::Mongo do
  subject { described_class.new(collection) }

  let(:host) { ENV['MONGODB_HOST'] || '127.0.0.1' }
  let(:port) { ENV['MONGODB_PORT'] || 27017 }

  let(:client) do
    logger = Logger.new('/dev/null')
    Mongo::Client.new(["#{host}:#{port}"], server_selection_timeout: 0.01, database: 'testing', logger: logger)
  end
  let(:collection) { client['testing'] }

  before do
    skip_on_error(Mongo::Error::NoServerAvailable, 'Mongo not available') do
      begin
        collection.drop
      rescue Mongo::Error::OperationFailure
      end
    end
    collection.create
  end

  it_should_behave_like 'a flipper adapter'

  it 'configures itself on load' do
    Flipper.configuration = nil
    Flipper.instance = nil

    load 'flipper/adapters/mongo.rb'

    ENV["MONGO_URL"] = ENV.fetch("MONGO_URL", "mongodb://127.0.0.1:27017/testing")
    expect(Flipper.adapter.adapter).to be_a(Flipper::Adapters::Mongo)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flipper-mongo-1.3.2 spec/flipper/adapters/mongo_spec.rb
flipper-mongo-1.3.1 spec/flipper/adapters/mongo_spec.rb
flipper-mongo-1.3.0 spec/flipper/adapters/mongo_spec.rb
flipper-mongo-1.3.0.pre spec/flipper/adapters/mongo_spec.rb
flipper-mongo-1.2.2 spec/flipper/adapters/mongo_spec.rb