aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
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/spec_helper.rb
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/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb24
1 files changed, 16 insertions, 8 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