Permalink
Browse files

Autoload AR test case

  • Loading branch information...
1 parent 640d9e7 commit e5ed62deea3f281f9dafc8e7c9ae4354b5ad6a27 @josh josh committed Jan 4, 2010
@@ -17,7 +17,6 @@ class ActiveRecordTestConnector
raise LoadError, "#{PATH_TO_AR} doesn't exist" unless File.directory?(PATH_TO_AR)
$LOAD_PATH.unshift PATH_TO_AR
require 'active_record'
- require 'active_record/fixtures'
rescue LoadError => e
$stderr.print "Failed to load Active Record. Skipping Active Record assertion tests: #{e}"
ActiveRecordTestConnector.able_to_connect = false
@@ -2,8 +2,6 @@
$:.unshift(File.dirname(__FILE__) + '/../../../activerecord/lib')
require 'active_record'
-require 'active_record/test_case'
-require 'active_record/fixtures'
module ActiveModel
module TestsDatabase
@@ -134,6 +134,9 @@ module ConnectionAdapters
autoload :AbstractAdapter
end
end
+
+ autoload :TestCase
+ autoload :TestFixtures, 'active_record/fixtures'
end
Arel::Table.engine = Arel::Sql::Engine.new(ActiveRecord::Base)
@@ -46,7 +46,7 @@ namespace :db do
$stderr.puts "Couldn't create database for #{config.inspect}"
end
end
- return # Skip the else clause of begin/rescue
+ return # Skip the else clause of begin/rescue
else
ActiveRecord::Base.establish_connection(config)
ActiveRecord::Base.connection
@@ -245,7 +245,6 @@ namespace :db do
namespace :fixtures do
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
task :load => :environment do
- require 'active_record/fixtures'
ActiveRecord::Base.establish_connection(Rails.env)
base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
@@ -257,8 +256,6 @@ namespace :db do
desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
task :identify => :environment do
- require "active_record/fixtures"
-
label, id = ENV["LABEL"], ENV["ID"]
raise "LABEL or ID required" if label.blank? && id.blank?
@@ -13,8 +13,6 @@
require 'stringio'
require 'active_record'
-require 'active_record/test_case'
-require 'active_record/fixtures'
require 'connection'
begin
@@ -9,9 +9,6 @@
require 'active_support/core_ext/kernel/requires'
if defined?(ActiveRecord)
- require 'active_record/test_case'
- require 'active_record/fixtures'
-
class ActiveSupport::TestCase
include ActiveRecord::TestFixtures
self.fixture_path = "#{Rails.root}/test/fixtures/"

0 comments on commit e5ed62d

Please sign in to comment.