Testcontainers::MongoContainer
Inherits Testcontainers::DockerContainer < Reference < Object
MongoContainer provides a pre-configured container for MongoDB.
Example:
container = Testcontainers::MongoContainer.new
container.start
url = container.connection_url
# => "mongodb://test:test@localhost:32768"
container.stop
container.remove
Constants
MONGO_DEFAULT_DATABASE = "test"
MONGO_DEFAULT_IMAGE = "mongo:latest"
MONGO_DEFAULT_PASSWORD = "test"
MONGO_DEFAULT_PORT = 27017
MONGO_DEFAULT_USERNAME = "test"
Constructors
Instance methods
connection_url(protocol : String = "mongodb", username : String | Nil = nil, password : String | Nil = nil, database : String | Nil = nil, options : Hash(String, String) = Hash(String, String).new) : String
Returns the MongoDB connection URL.
database
Sourcedatabase_url
Sourcepassword
Sourceport
Sourcestart
Starts the container.
This will:
- Pull the image if not present
- Create the container
- Start the container
- Execute the wait strategy (if any)
Returns self for method chaining.
username
Source