Sha256: ff77f240bf1ace92e77d07e32210f6d4391783a7754229f8aace13a6f9e9b461

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

require 'helper'
require 'flipper/adapters/mongo'
require 'flipper/spec/shared_adapter_specs'

describe Flipper::Adapters::Mongo do
  let(:collection) { Mongo::Connection.new.db('testing')['testing'] }
  let(:id)         { 'flipper' }

  subject { described_class.new(collection) }

  before do
    collection.remove
  end

  def read_key(key)
    if (doc = collection.find_one(:_id => key))
      value = doc['v']

      if value.is_a?(::Array)
        value = value.to_set
      end

      value
    end
  end

  def write_key(key, value)
    if value.is_a?(::Set)
      value = value.to_a
    end

    criteria = {:_id => key}
    updates  = {'$set' => {'v' => value}}
    options  = {:upsert => true}
    collection.update criteria, updates, options
  end

  it_should_behave_like 'a flipper adapter'
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flipper-mongo-0.2.2 spec/flipper/adapters/mongo_spec.rb
flipper-mongo-0.2.1 spec/flipper/adapters/mongo_spec.rb
flipper-mongo-0.2.0 spec/flipper/adapters/mongo_spec.rb