Sha256: 6c8a8cf9f84964e172d6f9ccb1ca2eba5be76496813cd7069eb0a7039971e4ea

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

require 'helper'

describe "BSON::ObjectId.to_store" do
  it "returns nil if value nil" do
    BSON::ObjectId.to_store(nil).should be_nil
  end

  it "returns value if already bson object id" do
    id = BSON::ObjectId.new
    BSON::ObjectId.to_store(id).should be(id)
  end

  it "returns bson object id if string and valid bson object id" do
    id = BSON::ObjectId.new
    BSON::ObjectId.to_store(id.to_s).should == id
  end
  
  it "returns whatever is passed in if not object id or string version of object id" do
    BSON::ObjectId.to_store('foo').should == 'foo'
  end
end

describe "BSON::ObjectId.from_store" do
  it "returns nil if value nil" do
    BSON::ObjectId.from_store(nil).should be_nil
  end

  it "returns value if already bson object id" do
    id = BSON::ObjectId.new
    BSON::ObjectId.from_store(id).should be(id)
  end

  it "returns bson object id if string and valid bson object id" do
    id = BSON::ObjectId.new
    BSON::ObjectId.from_store(id.to_s).should == id
  end
  
  it "returns whatever is passed in if not object id or string version of object id" do
    BSON::ObjectId.from_store('foo').should == 'foo'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
toystore-mongo-0.12.0 spec/toy/extensions/bson_object_id_spec.rb
toystore-mongo-0.11.0 spec/toy/extensions/bson_object_id_spec.rb
toystore-mongo-0.10.0 spec/toy/extensions/bson_object_id_spec.rb
toystore-mongo-0.9.0 spec/toy/extensions/bson_object_id_spec.rb
toystore-mongo-0.8.2 spec/toy/extensions/bson_object_id_spec.rb
toystore-mongo-0.8.1 spec/toy/extensions/bson_object_id_spec.rb
toystore-mongo-0.8.0 spec/toy/extensions/bson_object_id_spec.rb
toystore-mongo-0.7.0 spec/toy/extensions/bson_object_id_spec.rb