From 09765829d38e78c0d260aac805c9f405a1523d56 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 23 Mar 2010 12:05:35 -0700 Subject: Cleanup the spec helper and spec rake task a bit --- spec/spec_helper.rb | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'spec/spec_helper.rb') 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 -- cgit v1.2.3