Tests should use unique test db; Rakefile fixes

This commit is contained in:
Kyle Banker 2010-12-02 12:36:44 -05:00
parent 13a27771b0
commit ed06ae4342
2 changed files with 11 additions and 11 deletions

View File

@ -45,7 +45,7 @@ end
namespace :test do namespace :test do
desc "Test the driver with the c extension enabled." desc "Test the driver with the C extension enabled."
task :c do task :c do
ENV['C_EXT'] = 'TRUE' ENV['C_EXT'] = 'TRUE'
Rake::Task['test:unit'].invoke Rake::Task['test:unit'].invoke
@ -56,7 +56,7 @@ namespace :test do
ENV['C_EXT'] = nil ENV['C_EXT'] = nil
end end
desc "Test the driver using pure ruby (no c extension)" desc "Test the driver using pure ruby (no C extension)"
task :ruby do task :ruby do
ENV['C_EXT'] = nil ENV['C_EXT'] = nil
Rake::Task['test:unit'].invoke Rake::Task['test:unit'].invoke
@ -147,16 +147,17 @@ namespace :test do
end end
task :drop_databases do |t| task :drop_databases do |t|
puts "Dropping test database..." puts "Dropping test databases..."
require File.join(File.dirname(__FILE__), 'test', 'test_helper') require './lib/mongo'
include Mongo con = Mongo::Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost',
con = Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', ENV['MONGO_RUBY_DRIVER_PORT'] || Mongo::Connection::DEFAULT_PORT)
ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT) con.database_names.each do |name|
con.drop_database(MONGO_TEST_DB) con.drop_database(name) if name =~ /^ruby-test/
end
end end
end end
desc "Generate documentation" desc "Generate RDOC documentation"
task :rdoc do task :rdoc do
version = eval(File.read("mongo.gemspec")).version version = eval(File.read("mongo.gemspec")).version
out = File.join('html', version.to_s) out = File.join('html', version.to_s)
@ -188,7 +189,6 @@ namespace :gem do
desc "Install the optional c extensions" desc "Install the optional c extensions"
task :install_extensions do task :install_extensions do
sh "gem uninstall -x -a -I bson_ext"
sh "gem build bson_ext.gemspec" sh "gem build bson_ext.gemspec"
sh "gem install --no-rdoc --no-ri bson_ext-*.gem" sh "gem install --no-rdoc --no-ri bson_ext-*.gem"
sh "rm bson_ext-*.gem" sh "rm bson_ext-*.gem"

View File

@ -22,7 +22,7 @@ end
require 'bson_ext/cbson' if !(RUBY_PLATFORM =~ /java/) && ENV['C_EXT'] require 'bson_ext/cbson' if !(RUBY_PLATFORM =~ /java/) && ENV['C_EXT']
unless defined? MONGO_TEST_DB unless defined? MONGO_TEST_DB
MONGO_TEST_DB = 'mongo-ruby-test' MONGO_TEST_DB = 'ruby-test-' + BSON::ObjectId.new.to_s
end end
class Test::Unit::TestCase class Test::Unit::TestCase