spec/flipper/adapters/mongo_spec.rb in flipper-mongo-0.2.2 vs spec/flipper/adapters/mongo_spec.rb in flipper-mongo-0.3.0
- old
+ new
@@ -11,11 +11,11 @@
before do
collection.remove
end
def read_key(key)
- if (doc = collection.find_one(:_id => key))
+ if (doc = collection.find_one(:_id => key.to_s))
value = doc['v']
if value.is_a?(::Array)
value = value.to_set
end
@@ -23,14 +23,16 @@
value
end
end
def write_key(key, value)
- if value.is_a?(::Set)
- value = value.to_a
+ value = if value.is_a?(::Set)
+ value.to_a.map(&:to_s)
+ else
+ value.to_s
end
- criteria = {:_id => key}
+ criteria = {:_id => key.to_s}
updates = {'$set' => {'v' => value}}
options = {:upsert => true}
collection.update criteria, updates, options
end