Skip to content

Commit

Permalink
Only use pids in database id for specs running on travis
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Dec 18, 2011
1 parent d6248c3 commit 1fc16a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
22 changes: 11 additions & 11 deletions spec/functional/mongoid/config/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
context "when no pool size provided" do

let(:options) do
{ "uri" => "mongodb://mongoid:test@localhost:27017/mongoid_#{DATABASE_ID}" }
{ "uri" => "mongodb://mongoid:test@localhost:27017/#{database_id}" }
end

it "sets the node host to the uri host" do
Expand All @@ -65,7 +65,7 @@
end

it "sets the database name to the uri database name" do
master.name.should == "mongoid_#{DATABASE_ID}"
master.name.should == database_id
end

it "defaults the pool size to 1" do
Expand All @@ -77,7 +77,7 @@

let(:options) do
{
"uri" => "mongodb://mongoid:test@localhost:27017/mongoid_#{DATABASE_ID}",
"uri" => "mongodb://mongoid:test@localhost:27017/#{database_id}",
"pool_size" => 2,
"logger" => true
}
Expand All @@ -92,7 +92,7 @@
end

it "sets the database name to the uri database name" do
master.name.should == "mongoid_#{DATABASE_ID}"
master.name.should == database_id
end

it "sets the pool size" do
Expand All @@ -110,7 +110,7 @@
context "when a host is provided" do

let(:options) do
{ "host" => "localhost", "database" => "mongoid_#{DATABASE_ID}" }
{ "host" => "localhost", "database" => database_id }
end

it "sets the node host to the uri host" do
Expand All @@ -122,7 +122,7 @@
end

it "sets the database name to the uri database name" do
master.name.should == "mongoid_#{DATABASE_ID}"
master.name.should == database_id
end

it "sets the pool size to 1" do
Expand All @@ -133,7 +133,7 @@
context "when no host is provided" do

let(:options) do
{ "database" => "mongoid_#{DATABASE_ID}", "port" => 27017 }
{ "database" => database_id, "port" => 27017 }
end

it "sets the node host to localhost" do
Expand All @@ -145,14 +145,14 @@
end

it "sets the database name to the uri database name" do
master.name.should == "mongoid_#{DATABASE_ID}"
master.name.should == database_id
end
end

context "when a port is provided" do

let(:options) do
{ "database" => "mongoid_#{DATABASE_ID}", "port" => 27017 }
{ "database" => database_id, "port" => 27017 }
end

it "sets the node host to localhost" do
Expand All @@ -167,7 +167,7 @@
context "when no port is provided" do

let(:options) do
{ "database" => "mongoid_#{DATABASE_ID}" }
{ "database" => database_id }
end

it "sets the node host to localhost" do
Expand All @@ -183,7 +183,7 @@

let(:options) do
{
"database" => "mongoid_#{DATABASE_ID}",
"database" => database_id,
"username" => "mongoid",
"password" => "test"
}
Expand Down
11 changes: 8 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
require "ammeter/init"

LOGGER = Logger.new($stdout)
DATABASE_ID = Process.pid

def database_id
ENV["CI"] ? "mongoid_#{Process.pid}" : "mongoid_test"
end

Mongoid.configure do |config|
database = Mongo::Connection.new.db("mongoid_#{DATABASE_ID}")
database = Mongo::Connection.new.db(database_id)
database.add_user("mongoid", "test")
config.master = database
config.logger = nil
Expand Down Expand Up @@ -65,7 +68,9 @@ module MyExtension
end

config.after(:suite) do
Mongoid.master.connection.drop_database("mongoid_#{DATABASE_ID}")
if ENV["CI"]
Mongoid.master.connection.drop_database(database_id)
end
end

# We filter out specs that require authentication to MongoHQ if the
Expand Down

0 comments on commit 1fc16a4

Please sign in to comment.