spec/mongoid/extensions_spec.rb in mongoid-7.3.5 vs spec/mongoid/extensions_spec.rb in mongoid-7.4.0
- old
+ new
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-# encoding: utf-8
require "spec_helper"
describe BSON::ObjectId do
@@ -9,11 +8,23 @@
let(:object_id) do
described_class.new
end
- it "returns the $oid plus string" do
- expect(object_id.as_json).to eq("$oid" => object_id.to_s)
+ context "when object_id_as_json_oid is not set" do
+ config_override :object_id_as_json_oid, false
+
+ it "uses bson-ruby's implementation of as_json" do
+ expect(object_id.as_json).to eq(object_id.bson_ruby_as_json)
+ end
+ end
+
+ context "when object_id_as_json_oid is set" do
+ config_override :object_id_as_json_oid, true
+
+ it "returns the $oid plus string" do
+ expect(object_id.as_json).to eq("$oid" => object_id.to_s)
+ end
end
end
end
describe BSON::Document do