2009-03-01 08:45:58 +00:00
|
|
|
require 'rubygems'
|
2010-05-04 20:07:21 +00:00
|
|
|
Bundler.setup
|
2009-03-01 08:45:58 +00:00
|
|
|
require 'spec/expectations'
|
2010-05-04 20:07:21 +00:00
|
|
|
require 'ruby-debug'
|
2009-03-01 08:45:58 +00:00
|
|
|
|
2010-05-25 17:21:45 +00:00
|
|
|
DB_DIR = "#{File.dirname(__FILE__)}/../../db"
|
|
|
|
|
2010-05-16 21:26:56 +00:00
|
|
|
orm = ENV['ORM']
|
|
|
|
another_orm = ENV['ANOTHER_ORM']
|
|
|
|
strategy = ENV['STRATEGY']
|
2010-05-26 07:20:29 +00:00
|
|
|
multiple_db = ENV['MULTIPLE_DBS']
|
2009-03-01 08:45:58 +00:00
|
|
|
|
2009-05-07 15:36:02 +00:00
|
|
|
if orm && strategy
|
2010-05-25 17:21:45 +00:00
|
|
|
$:.unshift(File.dirname(__FILE__) + '/../../../lib')
|
|
|
|
require 'database_cleaner'
|
|
|
|
require 'database_cleaner/cucumber'
|
|
|
|
|
2010-05-04 20:07:21 +00:00
|
|
|
begin
|
2010-05-16 21:26:56 +00:00
|
|
|
require "#{File.dirname(__FILE__)}/../../lib/#{orm}_models"
|
2010-05-16 20:44:09 +00:00
|
|
|
rescue LoadError => e
|
2009-05-07 15:36:02 +00:00
|
|
|
raise "You don't have the #{orm} ORM installed"
|
|
|
|
end
|
2010-05-16 21:26:56 +00:00
|
|
|
|
|
|
|
if another_orm
|
|
|
|
begin
|
|
|
|
require "#{File.dirname(__FILE__)}/../../lib/#{another_orm}_models"
|
|
|
|
rescue LoadError => e
|
|
|
|
raise "You don't have the #{another_orm} ORM installed"
|
|
|
|
end
|
|
|
|
end
|
2010-05-25 17:21:45 +00:00
|
|
|
|
2009-03-01 08:45:58 +00:00
|
|
|
|
|
|
|
|
2010-05-25 17:21:45 +00:00
|
|
|
|
2010-05-26 07:20:29 +00:00
|
|
|
if multiple_db && another_orm
|
|
|
|
DatabaseCleaner[ orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym, {:connection => :one} ].strategy = strategy.to_sym
|
|
|
|
DatabaseCleaner[ another_orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym, {:connection => :two} ].strategy = strategy.to_sym
|
|
|
|
elsif another_orm
|
2010-05-25 17:21:45 +00:00
|
|
|
DatabaseCleaner[ orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym ].strategy = strategy.to_sym
|
|
|
|
DatabaseCleaner[ another_orm.gsub(/(.)([A-Z]+)/,'\1_\2').downcase.to_sym ].strategy = strategy.to_sym
|
2010-05-26 07:20:29 +00:00
|
|
|
else
|
|
|
|
DatabaseCleaner.strategy = strategy.to_sym
|
2010-05-25 17:21:45 +00:00
|
|
|
end
|
2009-05-07 15:36:02 +00:00
|
|
|
|
|
|
|
else
|
2010-05-25 17:21:45 +00:00
|
|
|
raise "Run 'ORM=activerecord|datamapper|mongomapper|couchpotato [ANOTHER_ORM=activerecord|datamapper|mongomapper|couchpotato] [MULTIPLE_DBS=true] STRATEGY=transaction|truncation cucumber examples/features'"
|
2009-05-07 15:36:02 +00:00
|
|
|
end
|