Sha256: 01ec92098e45d9e766e46c0d440f00c00c7f8ee96857f9d80080cc1bae52c5ec
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
Contents
require 'helper' describe Toy::Identity::ObjectIdKeyFactory do uses_constants('User') it "should use BSON::ObjectId as key_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(Toy::Identity::ObjectIdKeyFactory.new) User.attribute(:name, String) end it "returns BSON::ObjectId as .key_type" do User.key_type.should be(BSON::ObjectId) 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 = user.store.client.find_one(user.id)['_id'] key.should be_instance_of(BSON::ObjectId) user.id.should == key end end end
Version data entries
4 entries across 4 versions & 1 rubygems