test/unit/test_support.rb in mongo_mapper-0.7.3 vs test/unit/test_support.rb in mongo_mapper-0.7.4
- old
+ new
@@ -19,25 +19,25 @@
end
end
context "Binary#to_mongo" do
should "convert to byte buffer if not byte buffer" do
- Binary.to_mongo('asdfsadasdfs').is_a?(ByteBuffer).should be_true
+ Binary.to_mongo('asdfsadasdfs').is_a?(BSON::ByteBuffer).should be_true
end
should "be byte buffer if byte buffer" do
- Binary.to_mongo(ByteBuffer.new('asdfsadasdfs')).is_a?(ByteBuffer).should be_true
+ Binary.to_mongo(BSON::ByteBuffer.new('asdfsadasdfs')).is_a?(BSON::ByteBuffer).should be_true
end
should "be nil if nil" do
Binary.to_mongo(nil).should be_nil
end
end
context "Binary#from_mongo" do
should "return value" do
- buffer = ByteBuffer.new('asdfasdfasdf')
+ buffer = BSON::ByteBuffer.new('asdfasdfasdf')
Binary.from_mongo(buffer).to_s.should == buffer.to_s
end
end
context "Boolean#to_mongo" do
@@ -178,23 +178,23 @@
should "return nil if blank string" do
ObjectId.to_mongo('').should be_nil
end
should "return value if object id" do
- id = Mongo::ObjectID.new
+ id = BSON::ObjectID.new
ObjectId.to_mongo(id).should be(id)
end
should "return object id if string" do
- id = Mongo::ObjectID.new
+ id = BSON::ObjectID.new
ObjectId.to_mongo(id.to_s).should be(id)
end
end
context "ObjectId#from_mongo" do
should "return value" do
- id = Mongo::ObjectID.new
+ id = BSON::ObjectID.new
ObjectId.from_mongo(id).should == id
end
end
context "NilClass#to_mongo" do
@@ -354,17 +354,29 @@
Time.from_mongo(nil).should be_nil
Time.zone = nil
end
end
- context "Mongo::ObjectID.to_json" do
- should "convert object id to string" do
- id = Mongo::ObjectID.new
- id.to_json.should == %Q("#{id}")
+ context "BSON::ObjectID" do
+ context "#as_json" do
+ should "convert object id to string" do
+ id = BSON::ObjectID.new
+ id.as_json.should == id.to_s
+ end
end
-
- should "support ruby driver syntax also" do
- id = Mongo::ObjectID.new
- id.original_to_json.should == %Q({"$oid": "#{id}"})
+ context "#to_json" do
+ should "convert object id to string" do
+ id = BSON::ObjectID.new
+ id.to_json.should == %Q("#{id}")
+ end
+
+ should "support ruby driver syntax also" do
+ id = BSON::ObjectID.new
+ id.original_to_json.should == %Q({"$oid": "#{id}"})
+ end
end
+ end
+
+ context "BSON::ObjectID.to_json" do
+
end
end