aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-03-23 12:05:35 -0700
committerCarl Lerche <carllerche@mac.com>2010-03-23 12:05:35 -0700
commit09765829d38e78c0d260aac805c9f405a1523d56 (patch)
treee190d2bbca28e43b67510e0fdb912ab39606b268 /spec
parent195cc1402284d0e965cd96e572514fe2ff300788 (diff)
downloadrails-09765829d38e78c0d260aac805c9f405a1523d56.tar.gz
rails-09765829d38e78c0d260aac805c9f405a1523d56.tar.bz2
rails-09765829d38e78c0d260aac805c9f405a1523d56.zip
Cleanup the spec helper and spec rake task a bit
Diffstat (limited to 'spec')
-rw-r--r--spec/spec_helper.rb24
-rw-r--r--spec/support/connections/mysql_connection.rb6
-rw-r--r--spec/support/connections/oracle_connection.rb8
-rw-r--r--spec/support/connections/postgresql_connection.rb6
-rw-r--r--spec/support/connections/sqlite3_connection.rb4
5 files changed, 24 insertions, 24 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 5941840437..a52fa257b7 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -7,6 +7,10 @@ require 'pp'
require 'fileutils'
require 'arel'
+if adapter = ENV['ADAPTER']
+ require "support/connections/#{adapter}_connection.rb"
+end
+
Dir["#{dir}/{support,shared}/*.rb"].each do |file|
require file
end
@@ -16,13 +20,17 @@ Spec::Runner.configure do |config|
config.include AdapterGuards
config.include Check
- config.before do
- Arel::Table.engine = Arel::Sql::Engine.new(ActiveRecord::Base) if defined?(ActiveRecord::Base)
- end
-end
+ if defined?(ActiveRecord::Base)
+ tmp = File.expand_path('../../tmp', __FILE__)
-# load corresponding adapter using ADAPTER environment variable when running single *_spec.rb file
-if adapter = ENV['ADAPTER']
- require "#{dir}/support/connections/#{adapter}_connection.rb"
- require "#{dir}/support/schemas/#{adapter}_schema.rb"
+ FileUtils.mkdir_p(tmp)
+ ActiveRecord::Base.logger = Logger.new("#{tmp}/debug.log")
+ ActiveRecord::Base.establish_connection("unit")
+
+ require "support/schemas/#{ENV['ADAPTER']}_schema.rb"
+
+ config.before do
+ Arel::Table.engine = Arel::Sql::Engine.new(ActiveRecord::Base)
+ end
+ end
end
diff --git a/spec/support/connections/mysql_connection.rb b/spec/support/connections/mysql_connection.rb
index 66a53b5037..de9d05c2ce 100644
--- a/spec/support/connections/mysql_connection.rb
+++ b/spec/support/connections/mysql_connection.rb
@@ -2,7 +2,7 @@ puts "Using native MySQL"
require "active_record"
require 'logger'
-ActiveRecord::Base.logger = Logger.new("debug.log")
+ENV['ADAPTER'] = 'mysql'
ActiveRecord::Base.configurations = {
'unit' => {
@@ -11,6 +11,4 @@ ActiveRecord::Base.configurations = {
:encoding => 'utf8',
:database => 'arel_unit',
}
-}
-
-ActiveRecord::Base.establish_connection 'unit'
+} \ No newline at end of file
diff --git a/spec/support/connections/oracle_connection.rb b/spec/support/connections/oracle_connection.rb
index 05be04e410..c28602b134 100644
--- a/spec/support/connections/oracle_connection.rb
+++ b/spec/support/connections/oracle_connection.rb
@@ -2,11 +2,11 @@ puts "Using native Oracle"
require "active_record"
require 'logger'
+ENV['ADAPTER'] = 'oracle'
+
# Prepend oracle_enhanced local development directory in front of load path
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../../oracle-enhanced/lib"
-ActiveRecord::Base.logger = Logger.new("debug.log")
-
ActiveRecord::Base.configurations = {
'unit' => {
:adapter => 'oracle_enhanced',
@@ -14,6 +14,4 @@ ActiveRecord::Base.configurations = {
:password => 'arel_unit',
:database => 'orcl',
}
-}
-
-ActiveRecord::Base.establish_connection 'unit'
+} \ No newline at end of file
diff --git a/spec/support/connections/postgresql_connection.rb b/spec/support/connections/postgresql_connection.rb
index 0fb6dfe065..34d304efa9 100644
--- a/spec/support/connections/postgresql_connection.rb
+++ b/spec/support/connections/postgresql_connection.rb
@@ -2,7 +2,7 @@ puts "Using native PostgreSQL"
require "active_record"
require 'logger'
-ActiveRecord::Base.logger = Logger.new("debug.log")
+ENV['ADAPTER'] = 'postgresql'
ActiveRecord::Base.configurations = {
'unit' => {
@@ -10,6 +10,4 @@ ActiveRecord::Base.configurations = {
:encoding => 'utf8',
:database => 'arel_unit',
}
-}
-
-ActiveRecord::Base.establish_connection 'unit'
+} \ No newline at end of file
diff --git a/spec/support/connections/sqlite3_connection.rb b/spec/support/connections/sqlite3_connection.rb
index abdbd24fe4..4c8627c795 100644
--- a/spec/support/connections/sqlite3_connection.rb
+++ b/spec/support/connections/sqlite3_connection.rb
@@ -2,7 +2,7 @@ puts "Using native SQLite3"
require "active_record"
require 'logger'
-ActiveRecord::Base.logger = Logger.new("debug.log")
+ENV['ADAPTER'] = 'sqlite3'
db_file = "spec/support/fixtures/fixture_database.sqlite3"
@@ -22,5 +22,3 @@ unless File.exist?(db_file)
puts "Executing '#{sqlite_command}'"
raise "Seems that there is no sqlite3 executable available" unless system(sqlite_command)
end
-
-ActiveRecord::Base.establish_connection("unit")