Sha256: b074816061345c06f0f2548f5ce730ba17ba149785fa49d042b3d19bb1fd11bd

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

require 'teststrap'

context "mongoid_pk_factory" do
  example_document = Class.new
  example_document.class_eval do
    include Mongoid::Document
  end

  context "with default settings" do

    should "use object ID primary keys" do
      example_document.new.id
    end.matches(/^[a-f0-9]{24}$/i)

  end # with default settings

  context "with a pk factory set on the mongo driver" do
    setup do
      pk_factory = stub!
      pk_factory.create_pk(anything) { {:_id => "a_primary_key"} }
      stub(Mongoid.master).pk_factory { pk_factory }
    end

    should "use the pk generated by the factory" do
      example_document.new.id
    end.equals("a_primary_key")
  end # with a pk factory set on the mongo driver
end   # mongoid_pk_factory

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid_pk_factory-1.0.0 test/mongoid_pk_factory_test.rb