test/test_helper.rb in thoughtbot-shoulda-2.10.2 vs test/test_helper.rb in thoughtbot-shoulda-2.11.1
- old
+ new
@@ -1,21 +1,26 @@
require 'fileutils'
+require 'test/unit'
-# Load the environment
ENV['RAILS_ENV'] = 'test'
-rails_root = File.dirname(__FILE__) + '/rails_root'
+ENV['RAILS_VERSION'] ||= '2.3.8'
+RAILS_GEM_VERSION = ENV['RAILS_VERSION']
-require "#{rails_root}/config/environment.rb"
+if ENV['RAILS_VERSION'].to_s =~ /^2/
+ require 'test/rails2_test_helper'
+else
+ require 'test/rails3_test_helper'
+end
-# Load the testing framework
-require 'test_help'
-silence_warnings { RAILS_ENV = ENV['RAILS_ENV'] }
+shoulda_path = File.join(File.dirname(__FILE__), '..', 'lib')
+$LOAD_PATH << shoulda_path
+require 'shoulda'
# Run the migrations
ActiveRecord::Migration.verbose = false
-ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate")
+ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
# Setup the fixtures path
ActiveSupport::TestCase.fixture_path =
File.join(File.dirname(__FILE__), "fixtures")
@@ -23,6 +28,9 @@
self.use_transactional_fixtures = false
self.use_instantiated_fixtures = false
end
require 'test/fail_macros'
-require 'test/model_builder'
+
+Shoulda.autoload_macros File.join(File.dirname(__FILE__), 'rails2_root'),
+ File.join("vendor", "{plugins,gems}", "*")
+