spec/flipper/adapters/mongo_spec.rb in flipper-mongo-0.1.1 vs spec/flipper/adapters/mongo_spec.rb in flipper-mongo-0.2.0

- old
+ new

@@ -2,22 +2,21 @@ require 'flipper/adapters/mongo' require 'flipper/spec/shared_adapter_specs' describe Flipper::Adapters::Mongo do let(:collection) { Mongo::Connection.new.db('testing')['testing'] } - let(:criteria) { {:_id => id} } - let(:id) { described_class::DefaultId } + let(:id) { 'flipper' } - subject { Flipper::Adapters::Mongo.new(collection) } + subject { described_class.new(collection) } before do - collection.remove(criteria) + collection.remove end def read_key(key) - if (doc = collection.find_one(criteria)) - value = doc[key] + if (doc = collection.find_one(:_id => key)) + value = doc['v'] if value.is_a?(::Array) value = value.to_set end @@ -28,11 +27,12 @@ def write_key(key, value) if value.is_a?(::Set) value = value.to_a end - options = {:upsert => true} - updates = {'$set' => {key => value}} + criteria = {:_id => key} + updates = {'$set' => {'v' => value}} + options = {:upsert => true} collection.update criteria, updates, options end it_should_behave_like 'a flipper adapter' end