Sha256: 1e79043d4d543432db3a9ce5d1508c661879c427302212f1d33e908d13dac762
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
require 'helper' require 'toy/identity/object_id_key_factory' describe Toy::Identity::ObjectIdKeyFactory do uses_constants('User') it "should use String as store_type" do Toy::Identity::ObjectIdKeyFactory.new.key_type.should be(BSON::ObjectId) end it "should use object id for next key" do key = Toy::Identity::ObjectIdKeyFactory.new.next_key(nil) key.should be_instance_of(BSON::ObjectId) end describe "Declaring key to be object_id" do before(:each) do User.key(:object_id) User.attribute(:name, String) end it "sets id attribute to BSON::ObjectId type" do User.attributes['id'].type.should be(BSON::ObjectId) end it "correctly stores id in database" do user = User.create(:name => 'John') user.id.should be_instance_of(BSON::ObjectId) # key_for in memory adapter marshals non symbol/string keys # so we have to unmarshal to get the key type key = Marshal.load(user.store.client.keys.first) key.should be_instance_of(BSON::ObjectId) user.id.should == key end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
toystore-0.6.3 | spec/toy/identity/object_id_key_factory_spec.rb |
toystore-0.6.2 | spec/toy/identity/object_id_key_factory_spec.rb |