test/test_helper.rb in friendly_id-2.0.1 vs test/test_helper.rb in friendly_id-2.0.2
- old
+ new
@@ -1,35 +1,33 @@
$:.unshift(File.dirname(__FILE__) + '/../lib')
-$VERBOSE = false
-
-ENV['RAILS_ENV'] = 'test'
-require File.dirname(__FILE__) + '/rails/2.x/config/environment.rb'
-ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
-
+$:.unshift(File.dirname(__FILE__))
+$VERBOSE=false
+require 'rubygems'
require 'test/unit'
-require 'active_record/fixtures'
-require 'action_controller/test_process'
-require 'sqlite3'
-require 'friendly_id/slug'
-
-config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
-ActiveRecord::Base.establish_connection
-
-silence_stream(STDOUT) do
- load(File.dirname(__FILE__) + "/schema.rb")
+require 'shoulda'
+# You can use "rake test AR_VERSION=2.0.5" to test against 2.0.5, for example.
+# The default is to use the latest installed ActiveRecord.
+if ENV["AR_VERSION"]
+ gem 'activerecord', "#{ENV["AR_VERSION"]}"
end
+require 'active_record'
-Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures"
-$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
+require 'friendly_id'
+require 'models/post'
+require 'models/person'
+require 'models/user'
+require 'models/country'
-class Test::Unit::TestCase #:nodoc:
- include ActionController::TestProcess
- def create_fixtures(*table_names)
- if block_given?
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
- else
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
- end
- end
- self.use_transactional_fixtures = true
- self.use_instantiated_fixtures = false
+# Borrowed from ActiveSupport
+def silence_stream(stream)
+ old_stream = stream.dup
+ stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
+ stream.sync = true
+ yield
+ensure
+ stream.reopen(old_stream)
end
+
+ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
+silence_stream(STDOUT) do
+ load(File.dirname(__FILE__) + "/schema.rb")
+end
\ No newline at end of file