spec/support/client_registry_macros.rb in mongo-2.13.2 vs spec/support/client_registry_macros.rb in mongo-2.13.3
- old
+ new
@@ -1,12 +1,21 @@
module ClientRegistryMacros
- def new_local_client(address, options=nil)
- ClientRegistry.instance.new_local_client(address, options)
+ def new_local_client(address, options=nil, &block)
+ ClientRegistry.instance.new_local_client(address, options, &block)
end
- def new_local_client_nmio(address, options=nil)
- new_local_client(address, Mongo::Options::Redacted.new(
- monitoring_io: false).merge(options || {}))
+ def new_local_client_nmio(address, options=nil, &block)
+ # Avoid type converting options.
+ base_options = {monitoring_io: false}
+ if BSON::Document === options || options&.keys&.any? { |key| String === key }
+ base_options = Mongo::Options::Redacted.new(base_options)
+ end
+ options = if options
+ base_options.merge(options)
+ else
+ base_options
+ end
+ new_local_client(address, options, &block)
end
def close_local_clients
ClientRegistry.instance.close_local_clients
end