aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/lib/action_mailer/test_case.rb36
-rw-r--r--actionmailer/test/test_helper_test.rb10
-rw-r--r--actionpack/lib/action_controller/test_case.rb32
-rw-r--r--actionpack/lib/action_controller/test_process.rb1
-rw-r--r--actionpack/test/active_record_unit.rb2
-rw-r--r--actionpack/test/controller/test_test.rb11
-rwxr-xr-xactiverecord/lib/active_record/fixtures.rb149
-rw-r--r--activerecord/test/aaa_create_tables_test.rb2
-rwxr-xr-xactiverecord/test/abstract_unit.rb2
-rw-r--r--activerecord/test/active_schema_test_mysql.rb2
-rw-r--r--activerecord/test/adapter_test.rb2
-rw-r--r--activerecord/test/adapter_test_sqlserver.rb2
-rw-r--r--activerecord/test/aggregations_test.rb4
-rw-r--r--activerecord/test/ar_schema_test.rb2
-rw-r--r--activerecord/test/association_inheritance_reload.rb2
-rw-r--r--activerecord/test/associations/callbacks_test.rb2
-rw-r--r--activerecord/test/associations/cascaded_eager_loading_test.rb4
-rw-r--r--activerecord/test/associations/eager_singularization_test.rb2
-rw-r--r--activerecord/test/associations/eager_test.rb2
-rw-r--r--activerecord/test/associations/extension_test.rb2
-rw-r--r--activerecord/test/associations/inner_join_association_test.rb2
-rw-r--r--activerecord/test/associations/join_model_test.rb2
-rwxr-xr-xactiverecord/test/associations_test.rb14
-rwxr-xr-xactiverecord/test/attribute_methods_test.rb2
-rwxr-xr-xactiverecord/test/base_test.rb2
-rw-r--r--activerecord/test/binary_test.rb2
-rw-r--r--activerecord/test/calculations_test.rb2
-rw-r--r--activerecord/test/callbacks_test.rb2
-rw-r--r--activerecord/test/class_inheritable_attributes_test.rb2
-rw-r--r--activerecord/test/column_alias_test.rb2
-rw-r--r--activerecord/test/connection_test_firebird.rb2
-rw-r--r--activerecord/test/connection_test_mysql.rb2
-rw-r--r--activerecord/test/copy_table_test_sqlite.rb2
-rw-r--r--activerecord/test/datatype_test_postgresql.rb2
-rw-r--r--activerecord/test/date_time_test.rb2
-rw-r--r--activerecord/test/default_test_firebird.rb2
-rw-r--r--activerecord/test/defaults_test.rb2
-rwxr-xr-xactiverecord/test/deprecated_finder_test.rb2
-rw-r--r--activerecord/test/finder_test.rb2
-rwxr-xr-xactiverecord/test/fixtures_test.rb48
-rwxr-xr-xactiverecord/test/inheritance_test.rb4
-rw-r--r--activerecord/test/json_serialization_test.rb4
-rwxr-xr-xactiverecord/test/lifecycle_test.rb2
-rw-r--r--activerecord/test/locking_test.rb4
-rw-r--r--activerecord/test/method_scoping_test.rb12
-rw-r--r--activerecord/test/migration_test.rb4
-rw-r--r--activerecord/test/migration_test_firebird.rb2
-rw-r--r--activerecord/test/mixin_test.rb2
-rw-r--r--activerecord/test/modules_test.rb2
-rw-r--r--activerecord/test/multiple_db_test.rb2
-rw-r--r--activerecord/test/pk_test.rb2
-rw-r--r--activerecord/test/query_cache_test.rb4
-rwxr-xr-xactiverecord/test/readonly_test.rb2
-rw-r--r--activerecord/test/reflection_test.rb2
-rw-r--r--activerecord/test/reserved_word_test_mysql.rb2
-rw-r--r--activerecord/test/schema_authorization_test_postgresql.rb2
-rw-r--r--activerecord/test/schema_dumper_test.rb2
-rw-r--r--activerecord/test/schema_test_postgresql.rb2
-rw-r--r--activerecord/test/serialization_test.rb2
-rw-r--r--activerecord/test/synonym_test_oracle.rb2
-rw-r--r--activerecord/test/table_name_test_sqlserver.rb2
-rw-r--r--activerecord/test/threaded_connections_test.rb2
-rw-r--r--activerecord/test/transactions_test.rb2
-rwxr-xr-xactiverecord/test/unconnected_test.rb2
-rwxr-xr-xactiverecord/test/validations_test.rb4
-rw-r--r--activerecord/test/xml_serialization_test.rb8
-rw-r--r--activesupport/CHANGELOG4
-rw-r--r--activesupport/lib/active_support.rb3
-rw-r--r--activesupport/lib/active_support/test_case.rb12
-rw-r--r--activesupport/lib/active_support/testing.rb1
-rw-r--r--activesupport/lib/active_support/testing/default.rb9
-rw-r--r--activesupport/lib/active_support/testing/setup_and_teardown.rb127
-rw-r--r--activesupport/test/core_ext/load_error_test.rb (renamed from activesupport/test/core_ext/load_error_tests.rb)2
-rw-r--r--activesupport/test/test_test.rb46
74 files changed, 393 insertions, 260 deletions
diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb
index 7829baa799..d474afe3a2 100644
--- a/actionmailer/lib/action_mailer/test_case.rb
+++ b/actionmailer/lib/action_mailer/test_case.rb
@@ -8,11 +8,13 @@ module ActionMailer
"test case definition"
end
end
- # New Test Super class for forward compatibility.
- # To override
+
class TestCase < ActiveSupport::TestCase
include ActionMailer::Quoting
+ setup :initialize_test_deliveries
+ setup :set_expected_mail
+
class << self
def tests(mailer)
write_inheritable_attribute(:mailer_class, mailer)
@@ -33,28 +35,18 @@ module ActionMailer
end
end
- def setup_with_mailer
- ActionMailer::Base.delivery_method = :test
- ActionMailer::Base.perform_deliveries = true
- ActionMailer::Base.deliveries = []
-
- @expected = TMail::Mail.new
- @expected.set_content_type "text", "plain", { "charset" => charset }
- @expected.mime_version = '1.0'
- end
- alias_method :setup, :setup_with_mailer
+ protected
+ def initialize_test_deliveries
+ ActionMailer::Base.delivery_method = :test
+ ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.deliveries = []
+ end
- def self.method_added(method)
- if method.to_s == 'setup'
- unless method_defined?(:setup_without_mailer)
- alias_method :setup_without_mailer, :setup
- define_method(:setup) do
- setup_with_mailer
- setup_without_mailer
- end
- end
+ def set_expected_mail
+ @expected = TMail::Mail.new
+ @expected.set_content_type "text", "plain", { "charset" => charset }
+ @expected.mime_version = '1.0'
end
- end
private
def charset
diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb
index ab14bcc561..f8913e548c 100644
--- a/actionmailer/test/test_helper_test.rb
+++ b/actionmailer/test/test_helper_test.rb
@@ -9,7 +9,6 @@ class TestHelperMailer < ActionMailer::Base
end
class TestHelperMailerTest < ActionMailer::TestCase
-
def test_setup_sets_right_action_mailer_options
assert_equal :test, ActionMailer::Base.delivery_method
assert ActionMailer::Base.perform_deliveries
@@ -117,19 +116,14 @@ class TestHelperMailerTest < ActionMailer::TestCase
end
class AnotherTestHelperMailerTest < ActionMailer::TestCase
-
tests TestHelperMailer
def setup
- # Should not override ActionMailer setup methods
@test_var = "a value"
end
- def test_should_still_setup_mailer
+ def test_setup_shouldnt_conflict_with_mailer_setup
assert @expected.is_a?(TMail::Mail)
- end
-
- def test_should_run_overridden_setup_method
- assert @test_var
+ assert_equal 'a value', @test_var
end
end
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 84610c34c0..431876a72e 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -10,7 +10,16 @@ module ActionController
end
class TestCase < ActiveSupport::TestCase
+ module RaiseActionExceptions
+ def rescue_action(e)
+ raise e
+ end
+ end
+
+ setup :setup_controller_request_and_response
+
@@controller_class = nil
+
class << self
def tests(controller_class)
self.controller_class = controller_class
@@ -25,7 +34,7 @@ module ActionController
if current_controller_class = read_inheritable_attribute(:controller_class)
current_controller_class
else
- self.controller_class= determine_default_controller_class(name)
+ self.controller_class = determine_default_controller_class(name)
end
end
@@ -36,31 +45,14 @@ module ActionController
end
def prepare_controller_class(new_class)
- new_class.class_eval do
- def rescue_action(e)
- raise e
- end
- end
+ new_class.send :include, RaiseActionExceptions
end
end
- def setup_with_controller
+ def setup_controller_request_and_response
@controller = self.class.controller_class.new
@request = TestRequest.new
@response = TestResponse.new
end
- alias_method :setup, :setup_with_controller
-
- def self.method_added(method)
- if method.to_s == 'setup'
- unless method_defined?(:setup_without_controller)
- alias_method :setup_without_controller, :setup
- define_method(:setup) do
- setup_with_controller
- setup_without_controller
- end
- end
- end
- end
end
end
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 4cbb695f4c..ba23f012da 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -1,4 +1,5 @@
require 'action_controller/assertions'
+require 'action_controller/test_case'
module ActionController #:nodoc:
class Base
diff --git a/actionpack/test/active_record_unit.rb b/actionpack/test/active_record_unit.rb
index d4cc474478..a7d526850e 100644
--- a/actionpack/test/active_record_unit.rb
+++ b/actionpack/test/active_record_unit.rb
@@ -84,7 +84,7 @@ class ActiveRecordTestConnector
end
end
-class ActiveRecordTestCase < Test::Unit::TestCase
+class ActiveRecordTestCase < ActiveSupport::TestCase
# Set our fixture path
if ActiveRecordTestConnector.able_to_connect
self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 57c97a326c..b3a8e8750b 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -613,18 +613,9 @@ class InferringClassNameTest < Test::Unit::TestCase
end
end
-class ContentControllerTest < ActionController::TestCase
- def setup
- # Should not override ActionController setup methods
- end
-
- def test_should_still_setup_controller
- assert_kind_of(ContentController, @controller)
- end
-end
-
class CrazyNameTest < ActionController::TestCase
tests ContentController
+
def test_controller_class_can_be_set_manually_not_just_inferred
assert_equal ContentController, self.class.controller_class
end
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index bbd42c5a80..7ee17ac8b0 100755
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -1,11 +1,14 @@
require 'erb'
require 'yaml'
require 'csv'
+require 'active_support/test_case'
-module YAML #:nodoc:
- class Omap #:nodoc:
- def keys; map { |k, v| k } end
- def values; map { |k, v| v } end
+if RUBY_VERSION < '1.9'
+ module YAML #:nodoc:
+ class Omap #:nodoc:
+ def keys; map { |k, v| k } end
+ def values; map { |k, v| v } end
+ end
end
end
@@ -29,7 +32,7 @@ end
# in a non-verbose, human-readable format. It ships with Ruby 1.8.1+.
#
# Unlike single-file fixtures, YAML fixtures are stored in a single file per model, which are placed in the directory appointed
-# by <tt>Test::Unit::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just
+# by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just
# put your files in <your-rails-app>/test/fixtures/). The fixture file ends with the .yml file extension (Rails example:
# "<your-rails-app>/test/fixtures/web_sites.yml"). The format of a YAML fixture file looks like this:
#
@@ -89,7 +92,7 @@ end
#
# This type of fixture was the original format for Active Record that has since been deprecated in favor of the YAML and CSV formats.
# Fixtures for this format are created by placing text files in a sub-directory (with the name of the model) to the directory
-# appointed by <tt>Test::Unit::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just
+# appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just
# put your files in <your-rails-app>/test/fixtures/<your-model-name>/ -- like <your-rails-app>/test/fixtures/web_sites/ for the WebSite
# model).
#
@@ -115,7 +118,7 @@ end
#
# require 'web_site'
#
-# class WebSiteTest < Test::Unit::TestCase
+# class WebSiteTest < ActiveSupport::TestCase
# def test_web_site_count
# assert_equal 2, WebSite.count
# end
@@ -125,7 +128,7 @@ end
# easiest way to add fixtures to the database:
#
# ...
-# class WebSiteTest < Test::Unit::TestCase
+# class WebSiteTest < ActiveSupport::TestCase
# fixtures :web_sites # add more by separating the symbols with commas
# ...
#
@@ -191,7 +194,7 @@ end
# TestCases can use begin+rollback to isolate their changes to the database instead of having to delete+insert for every test case.
# They can also turn off auto-instantiation of fixture data since the feature is costly and often unused.
#
-# class FooTest < Test::Unit::TestCase
+# class FooTest < ActiveSupport::TestCase
# self.use_transactional_fixtures = true
# self.use_instantiated_fixtures = false
#
@@ -842,6 +845,9 @@ end
module Test #:nodoc:
module Unit #:nodoc:
class TestCase #:nodoc:
+ setup :setup_fixtures
+ teardown :teardown_fixtures
+
superclass_delegating_accessor :fixture_path
superclass_delegating_accessor :fixture_table_names
superclass_delegating_accessor :fixture_class_names
@@ -857,68 +863,70 @@ module Test #:nodoc:
@@already_loaded_fixtures = {}
self.fixture_class_names = {}
- def self.set_fixture_class(class_names = {})
- self.fixture_class_names = self.fixture_class_names.merge(class_names)
- end
-
- def self.fixtures(*table_names)
- if table_names.first == :all
- table_names = Dir["#{fixture_path}/*.yml"] + Dir["#{fixture_path}/*.csv"]
- table_names.map! { |f| File.basename(f).split('.')[0..-2].join('.') }
- else
- table_names = table_names.flatten.map { |n| n.to_s }
+ class << self
+ def set_fixture_class(class_names = {})
+ self.fixture_class_names = self.fixture_class_names.merge(class_names)
end
- self.fixture_table_names |= table_names
- require_fixture_classes(table_names)
- setup_fixture_accessors(table_names)
- end
+ def fixtures(*table_names)
+ if table_names.first == :all
+ table_names = Dir["#{fixture_path}/*.yml"] + Dir["#{fixture_path}/*.csv"]
+ table_names.map! { |f| File.basename(f).split('.')[0..-2].join('.') }
+ else
+ table_names = table_names.flatten.map { |n| n.to_s }
+ end
- def self.require_fixture_classes(table_names = nil)
- (table_names || fixture_table_names).each do |table_name|
- file_name = table_name.to_s
- file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names
- begin
- require_dependency file_name
- rescue LoadError
- # Let's hope the developer has included it himself
+ self.fixture_table_names |= table_names
+ require_fixture_classes(table_names)
+ setup_fixture_accessors(table_names)
+ end
+
+ def require_fixture_classes(table_names = nil)
+ (table_names || fixture_table_names).each do |table_name|
+ file_name = table_name.to_s
+ file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names
+ begin
+ require_dependency file_name
+ rescue LoadError
+ # Let's hope the developer has included it himself
+ end
end
end
- end
- def self.setup_fixture_accessors(table_names = nil)
- table_names = [table_names] if table_names && !table_names.respond_to?(:each)
- (table_names || fixture_table_names).each do |table_name|
- table_name = table_name.to_s.tr('.', '_')
+ def setup_fixture_accessors(table_names = nil)
+ table_names = [table_names] if table_names && !table_names.respond_to?(:each)
+ (table_names || fixture_table_names).each do |table_name|
+ table_name = table_name.to_s.tr('.', '_')
- define_method(table_name) do |*fixtures|
- force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload
+ define_method(table_name) do |*fixtures|
+ force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload
- @fixture_cache[table_name] ||= {}
+ @fixture_cache[table_name] ||= {}
- instances = fixtures.map do |fixture|
- @fixture_cache[table_name].delete(fixture) if force_reload
+ instances = fixtures.map do |fixture|
+ @fixture_cache[table_name].delete(fixture) if force_reload
- if @loaded_fixtures[table_name][fixture.to_s]
- @fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find
- else
- raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'"
+ if @loaded_fixtures[table_name][fixture.to_s]
+ @fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find
+ else
+ raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'"
+ end
end
- end
- instances.size == 1 ? instances.first : instances
+ instances.size == 1 ? instances.first : instances
+ end
end
end
- end
- def self.uses_transaction(*methods)
- @uses_transaction = [] unless defined?(@uses_transaction)
- @uses_transaction.concat methods.map(&:to_s)
- end
+ def uses_transaction(*methods)
+ @uses_transaction = [] unless defined?(@uses_transaction)
+ @uses_transaction.concat methods.map(&:to_s)
+ end
- def self.uses_transaction?(method)
- @uses_transaction = [] unless defined?(@uses_transaction)
- @uses_transaction.include?(method.to_s)
+ def uses_transaction?(method)
+ @uses_transaction = [] unless defined?(@uses_transaction)
+ @uses_transaction.include?(method.to_s)
+ end
end
def use_transactional_fixtures?
@@ -926,8 +934,8 @@ module Test #:nodoc:
!self.class.uses_transaction?(method_name)
end
- def setup_with_fixtures
- return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
+ def setup_fixtures
+ return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
if pre_loaded_fixtures && !use_transactional_fixtures
raise RuntimeError, 'pre_loaded_fixtures requires use_transactional_fixtures'
@@ -955,10 +963,9 @@ module Test #:nodoc:
# Instantiate fixtures for every test if requested.
instantiate_fixtures if use_instantiated_fixtures
end
- alias_method :setup, :setup_with_fixtures
- def teardown_with_fixtures
- return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
+ def teardown_fixtures
+ return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
unless use_transactional_fixtures?
Fixtures.reset_cache
@@ -971,28 +978,6 @@ module Test #:nodoc:
end
ActiveRecord::Base.verify_active_connections!
end
- alias_method :teardown, :teardown_with_fixtures
-
- def self.method_added(method)
- case method.to_s
- when 'setup'
- unless method_defined?(:setup_without_fixtures)
- alias_method :setup_without_fixtures, :setup
- define_method(:setup) do
- setup_with_fixtures
- setup_without_fixtures
- end
- end
- when 'teardown'
- unless method_defined?(:teardown_without_fixtures)
- alias_method :teardown_without_fixtures, :teardown
- define_method(:teardown) do
- teardown_without_fixtures
- teardown_with_fixtures
- end
- end
- end
- end
private
def load_fixtures
diff --git a/activerecord/test/aaa_create_tables_test.rb b/activerecord/test/aaa_create_tables_test.rb
index 7703c76a35..f255182952 100644
--- a/activerecord/test/aaa_create_tables_test.rb
+++ b/activerecord/test/aaa_create_tables_test.rb
@@ -1,7 +1,7 @@
# The filename begins with "aaa" to ensure this is the first test.
require 'abstract_unit'
-class AAACreateTablesTest < Test::Unit::TestCase
+class AAACreateTablesTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
def setup
diff --git a/activerecord/test/abstract_unit.rb b/activerecord/test/abstract_unit.rb
index a09c8daad5..8bd61da272 100755
--- a/activerecord/test/abstract_unit.rb
+++ b/activerecord/test/abstract_unit.rb
@@ -13,7 +13,7 @@ ActiveSupport::Deprecation.debug = true
QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') unless Object.const_defined?(:QUOTED_TYPE)
-class Test::Unit::TestCase #:nodoc:
+class ActiveSupport::TestCase #:nodoc:
self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
self.use_instantiated_fixtures = false
self.use_transactional_fixtures = (ENV['AR_NO_TX_FIXTURES'] != "yes")
diff --git a/activerecord/test/active_schema_test_mysql.rb b/activerecord/test/active_schema_test_mysql.rb
index f00dfd7902..336f74d234 100644
--- a/activerecord/test/active_schema_test_mysql.rb
+++ b/activerecord/test/active_schema_test_mysql.rb
@@ -1,6 +1,6 @@
require 'abstract_unit'
-class ActiveSchemaTest < Test::Unit::TestCase
+class ActiveSchemaTest < ActiveSupport::TestCase
def setup
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
alias_method :execute_without_stub, :execute
diff --git a/activerecord/test/adapter_test.rb b/activerecord/test/adapter_test.rb
index 4247bf8618..d93a99d7cd 100644
--- a/activerecord/test/adapter_test.rb
+++ b/activerecord/test/adapter_test.rb
@@ -1,6 +1,6 @@
require 'abstract_unit'
-class AdapterTest < Test::Unit::TestCase
+class AdapterTest < ActiveSupport::TestCase
def setup
@connection = ActiveRecord::Base.connection
end
diff --git a/activerecord/test/adapter_test_sqlserver.rb b/activerecord/test/adapter_test_sqlserver.rb
index 548668d5e7..0556466bbd 100644
--- a/activerecord/test/adapter_test_sqlserver.rb
+++ b/activerecord/test/adapter_test_sqlserver.rb
@@ -3,7 +3,7 @@ require 'fixtures/default'
require 'fixtures/post'
require 'fixtures/task'
-class SqlServerAdapterTest < Test::Unit::TestCase
+class SqlServerAdapterTest < ActiveSupport::TestCase
class TableWithRealColumn < ActiveRecord::Base; end
fixtures :posts, :tasks
diff --git a/activerecord/test/aggregations_test.rb b/activerecord/test/aggregations_test.rb
index caa26a2091..ea041fe955 100644
--- a/activerecord/test/aggregations_test.rb
+++ b/activerecord/test/aggregations_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/customer'
-class AggregationsTest < Test::Unit::TestCase
+class AggregationsTest < ActiveSupport::TestCase
fixtures :customers
def test_find_single_value_object
@@ -109,7 +109,7 @@ class AggregationsTest < Test::Unit::TestCase
end
end
-class OverridingAggregationsTest < Test::Unit::TestCase
+class OverridingAggregationsTest < ActiveSupport::TestCase
class Name; end
class DifferentName; end
diff --git a/activerecord/test/ar_schema_test.rb b/activerecord/test/ar_schema_test.rb
index c700b85eac..c3dca54a94 100644
--- a/activerecord/test/ar_schema_test.rb
+++ b/activerecord/test/ar_schema_test.rb
@@ -3,7 +3,7 @@ require "#{File.dirname(__FILE__)}/../lib/active_record/schema"
if ActiveRecord::Base.connection.supports_migrations?
- class ActiveRecordSchemaTest < Test::Unit::TestCase
+ class ActiveRecordSchemaTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
def setup
diff --git a/activerecord/test/association_inheritance_reload.rb b/activerecord/test/association_inheritance_reload.rb
index a3d5722841..5577f86eb3 100644
--- a/activerecord/test/association_inheritance_reload.rb
+++ b/activerecord/test/association_inheritance_reload.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/company'
-class AssociationInheritanceReloadTest < Test::Unit::TestCase
+class AssociationInheritanceReloadTest < ActiveSupport::TestCase
fixtures :companies
def test_set_attributes
diff --git a/activerecord/test/associations/callbacks_test.rb b/activerecord/test/associations/callbacks_test.rb
index 6df8718e28..29f93788e5 100644
--- a/activerecord/test/associations/callbacks_test.rb
+++ b/activerecord/test/associations/callbacks_test.rb
@@ -6,7 +6,7 @@ require 'fixtures/category'
require 'fixtures/project'
require 'fixtures/developer'
-class AssociationCallbacksTest < Test::Unit::TestCase
+class AssociationCallbacksTest < ActiveSupport::TestCase
fixtures :posts, :authors, :projects, :developers
def setup
diff --git a/activerecord/test/associations/cascaded_eager_loading_test.rb b/activerecord/test/associations/cascaded_eager_loading_test.rb
index 6361d584ab..9d6dffbd48 100644
--- a/activerecord/test/associations/cascaded_eager_loading_test.rb
+++ b/activerecord/test/associations/cascaded_eager_loading_test.rb
@@ -8,7 +8,7 @@ require 'fixtures/company'
require 'fixtures/topic'
require 'fixtures/reply'
-class CascadedEagerLoadingTest < Test::Unit::TestCase
+class CascadedEagerLoadingTest < ActiveSupport::TestCase
fixtures :authors, :mixins, :companies, :posts, :topics
def test_eager_association_loading_with_cascaded_two_levels
@@ -95,7 +95,7 @@ end
require 'fixtures/vertex'
require 'fixtures/edge'
-class CascadedEagerLoadingTest < Test::Unit::TestCase
+class CascadedEagerLoadingTest < ActiveSupport::TestCase
fixtures :edges, :vertices
def test_eager_association_loading_with_recursive_cascading_four_levels_has_many_through
diff --git a/activerecord/test/associations/eager_singularization_test.rb b/activerecord/test/associations/eager_singularization_test.rb
index 72164c4f1a..2990684afc 100644
--- a/activerecord/test/associations/eager_singularization_test.rb
+++ b/activerecord/test/associations/eager_singularization_test.rb
@@ -39,7 +39,7 @@ class Compress < ActiveRecord::Base
end
-class EagerSingularizationTest < Test::Unit::TestCase
+class EagerSingularizationTest < ActiveSupport::TestCase
def setup
if ActiveRecord::Base.connection.supports_migrations?
diff --git a/activerecord/test/associations/eager_test.rb b/activerecord/test/associations/eager_test.rb
index 69b1584b63..bdadada3f4 100644
--- a/activerecord/test/associations/eager_test.rb
+++ b/activerecord/test/associations/eager_test.rb
@@ -7,7 +7,7 @@ require 'fixtures/company'
require 'fixtures/person'
require 'fixtures/reader'
-class EagerAssociationTest < Test::Unit::TestCase
+class EagerAssociationTest < ActiveSupport::TestCase
fixtures :posts, :comments, :authors, :categories, :categories_posts,
:companies, :accounts, :tags, :people, :readers
diff --git a/activerecord/test/associations/extension_test.rb b/activerecord/test/associations/extension_test.rb
index 67a9ee02ad..3749f7ac41 100644
--- a/activerecord/test/associations/extension_test.rb
+++ b/activerecord/test/associations/extension_test.rb
@@ -4,7 +4,7 @@ require 'fixtures/comment'
require 'fixtures/project'
require 'fixtures/developer'
-class AssociationsExtensionsTest < Test::Unit::TestCase
+class AssociationsExtensionsTest < ActiveSupport::TestCase
fixtures :projects, :developers, :developers_projects, :comments, :posts
def test_extension_on_has_many
diff --git a/activerecord/test/associations/inner_join_association_test.rb b/activerecord/test/associations/inner_join_association_test.rb
index d2ba4ef634..b108ee560c 100644
--- a/activerecord/test/associations/inner_join_association_test.rb
+++ b/activerecord/test/associations/inner_join_association_test.rb
@@ -5,7 +5,7 @@ require 'fixtures/author'
require 'fixtures/category'
require 'fixtures/categorization'
-class InnerJoinAssociationTest < Test::Unit::TestCase
+class InnerJoinAssociationTest < ActiveSupport::TestCase
fixtures :authors, :posts, :comments, :categories, :categories_posts, :categorizations
def test_construct_finder_sql_creates_inner_joins
diff --git a/activerecord/test/associations/join_model_test.rb b/activerecord/test/associations/join_model_test.rb
index b970d054c4..d55faf70c6 100644
--- a/activerecord/test/associations/join_model_test.rb
+++ b/activerecord/test/associations/join_model_test.rb
@@ -12,7 +12,7 @@ require 'fixtures/edge'
require 'fixtures/book'
require 'fixtures/citation'
-class AssociationsJoinModelTest < Test::Unit::TestCase
+class AssociationsJoinModelTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices, :items, :books
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 7773b2bfb0..1749751852 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -17,7 +17,7 @@ require 'fixtures/tagging'
require 'fixtures/person'
require 'fixtures/reader'
-class AssociationsTest < Test::Unit::TestCase
+class AssociationsTest < ActiveSupport::TestCase
fixtures :accounts, :companies, :developers, :projects, :developers_projects,
:computers
@@ -73,7 +73,7 @@ class AssociationsTest < Test::Unit::TestCase
end
end
-class AssociationProxyTest < Test::Unit::TestCase
+class AssociationProxyTest < ActiveSupport::TestCase
fixtures :authors, :posts, :categorizations, :categories, :developers, :projects, :developers_projects
def test_proxy_accessors
@@ -166,7 +166,7 @@ class AssociationProxyTest < Test::Unit::TestCase
end
end
-class HasOneAssociationsTest < Test::Unit::TestCase
+class HasOneAssociationsTest < ActiveSupport::TestCase
fixtures :accounts, :companies, :developers, :projects, :developers_projects
def setup
@@ -463,7 +463,7 @@ class HasOneAssociationsTest < Test::Unit::TestCase
end
-class HasManyAssociationsTest < Test::Unit::TestCase
+class HasManyAssociationsTest < ActiveSupport::TestCase
fixtures :accounts, :companies, :developers, :projects,
:developers_projects, :topics, :authors, :comments
@@ -1196,7 +1196,7 @@ class HasManyAssociationsTest < Test::Unit::TestCase
end
-class BelongsToAssociationsTest < Test::Unit::TestCase
+class BelongsToAssociationsTest < ActiveSupport::TestCase
fixtures :accounts, :companies, :developers, :projects, :topics,
:developers_projects, :computers, :authors, :posts, :tags, :taggings
@@ -1572,7 +1572,7 @@ class DeveloperForProjectWithAfterCreateHook < ActiveRecord::Base
end
-class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
+class HasAndBelongsToManyAssociationsTest < ActiveSupport::TestCase
fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects
def test_has_and_belongs_to_many
@@ -2112,7 +2112,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
end
-class OverridingAssociationsTest < Test::Unit::TestCase
+class OverridingAssociationsTest < ActiveSupport::TestCase
class Person < ActiveRecord::Base; end
class DifferentPerson < ActiveRecord::Base; end
diff --git a/activerecord/test/attribute_methods_test.rb b/activerecord/test/attribute_methods_test.rb
index 8646afdcb5..8ff52802ac 100755
--- a/activerecord/test/attribute_methods_test.rb
+++ b/activerecord/test/attribute_methods_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/topic'
-class AttributeMethodsTest < Test::Unit::TestCase
+class AttributeMethodsTest < ActiveSupport::TestCase
fixtures :topics
def setup
@old_suffixes = ActiveRecord::Base.send(:attribute_method_suffixes).dup
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index b140e9ce54..276b7e100e 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -70,7 +70,7 @@ class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base
attr_protected :content
end
-class BasicsTest < Test::Unit::TestCase
+class BasicsTest < ActiveSupport::TestCase
fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics
def test_table_exists
diff --git a/activerecord/test/binary_test.rb b/activerecord/test/binary_test.rb
index 6ab272fe25..f89660e4e1 100644
--- a/activerecord/test/binary_test.rb
+++ b/activerecord/test/binary_test.rb
@@ -10,7 +10,7 @@ require 'abstract_unit'
unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
require 'fixtures/binary'
- class BinaryTest < Test::Unit::TestCase
+ class BinaryTest < ActiveSupport::TestCase
FIXTURES = %w(flowers.jpg example.log)
def test_load_save
diff --git a/activerecord/test/calculations_test.rb b/activerecord/test/calculations_test.rb
index 298a1d1878..bce84478b0 100644
--- a/activerecord/test/calculations_test.rb
+++ b/activerecord/test/calculations_test.rb
@@ -8,7 +8,7 @@ class NumericData < ActiveRecord::Base
self.table_name = 'numeric_data'
end
-class CalculationsTest < Test::Unit::TestCase
+class CalculationsTest < ActiveSupport::TestCase
fixtures :companies, :accounts, :topics
def test_should_sum_field
diff --git a/activerecord/test/callbacks_test.rb b/activerecord/test/callbacks_test.rb
index 6ec27e2455..5461d8e110 100644
--- a/activerecord/test/callbacks_test.rb
+++ b/activerecord/test/callbacks_test.rb
@@ -126,7 +126,7 @@ class CallbackCancellationDeveloper < ActiveRecord::Base
end
end
-class CallbacksTest < Test::Unit::TestCase
+class CallbacksTest < ActiveSupport::TestCase
fixtures :developers
def test_initialize
diff --git a/activerecord/test/class_inheritable_attributes_test.rb b/activerecord/test/class_inheritable_attributes_test.rb
index a3f94e3abb..3a29a3befb 100644
--- a/activerecord/test/class_inheritable_attributes_test.rb
+++ b/activerecord/test/class_inheritable_attributes_test.rb
@@ -19,7 +19,7 @@ class D < B
end
-class ClassInheritableAttributesTest < Test::Unit::TestCase
+class ClassInheritableAttributesTest < ActiveSupport::TestCase
def test_first_level
assert_equal [ :one, :two ], B.read_inheritable_attribute("first")
assert_equal [ :three ], C.read_inheritable_attribute("first")
diff --git a/activerecord/test/column_alias_test.rb b/activerecord/test/column_alias_test.rb
index 19526cf9b3..da4b66554a 100644
--- a/activerecord/test/column_alias_test.rb
+++ b/activerecord/test/column_alias_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/topic'
-class TestColumnAlias < Test::Unit::TestCase
+class TestColumnAlias < ActiveSupport::TestCase
fixtures :topics
QUERY = if 'Oracle' == ActiveRecord::Base.connection.adapter_name
diff --git a/activerecord/test/connection_test_firebird.rb b/activerecord/test/connection_test_firebird.rb
index 715e695518..eb0222b66f 100644
--- a/activerecord/test/connection_test_firebird.rb
+++ b/activerecord/test/connection_test_firebird.rb
@@ -1,6 +1,6 @@
require "#{File.dirname(__FILE__)}/abstract_unit"
-class FirebirdConnectionTest < Test::Unit::TestCase
+class FirebirdConnectionTest < ActiveSupport::TestCase
def test_charset_properly_set
fb_conn = ActiveRecord::Base.connection.instance_variable_get(:@connection)
assert_equal 'UTF8', fb_conn.database.character_set
diff --git a/activerecord/test/connection_test_mysql.rb b/activerecord/test/connection_test_mysql.rb
index e3f589c4af..e49a326d2b 100644
--- a/activerecord/test/connection_test_mysql.rb
+++ b/activerecord/test/connection_test_mysql.rb
@@ -1,6 +1,6 @@
require "#{File.dirname(__FILE__)}/abstract_unit"
-class MysqlConnectionTest < Test::Unit::TestCase
+class MysqlConnectionTest < ActiveSupport::TestCase
def setup
@connection = ActiveRecord::Base.connection
end
diff --git a/activerecord/test/copy_table_test_sqlite.rb b/activerecord/test/copy_table_test_sqlite.rb
index a25780e6be..f4933d5362 100644
--- a/activerecord/test/copy_table_test_sqlite.rb
+++ b/activerecord/test/copy_table_test_sqlite.rb
@@ -1,6 +1,6 @@
require 'abstract_unit'
-class CopyTableTest < Test::Unit::TestCase
+class CopyTableTest < ActiveSupport::TestCase
fixtures :companies, :comments
def setup
diff --git a/activerecord/test/datatype_test_postgresql.rb b/activerecord/test/datatype_test_postgresql.rb
index 53961135c3..cd881bb498 100644
--- a/activerecord/test/datatype_test_postgresql.rb
+++ b/activerecord/test/datatype_test_postgresql.rb
@@ -21,7 +21,7 @@ end
class PostgresqlOid < ActiveRecord::Base
end
-class PostgresqlDataTypeTest < Test::Unit::TestCase
+class PostgresqlDataTypeTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
def setup
diff --git a/activerecord/test/date_time_test.rb b/activerecord/test/date_time_test.rb
index 3bd44fd47b..23b2757d2a 100644
--- a/activerecord/test/date_time_test.rb
+++ b/activerecord/test/date_time_test.rb
@@ -2,7 +2,7 @@ require 'abstract_unit'
require 'fixtures/topic'
require 'fixtures/task'
-class DateTimeTest < Test::Unit::TestCase
+class DateTimeTest < ActiveSupport::TestCase
def test_saves_both_date_and_time
time_values = [1807, 2, 10, 15, 30, 45]
now = DateTime.civil(*time_values)
diff --git a/activerecord/test/default_test_firebird.rb b/activerecord/test/default_test_firebird.rb
index 4f3d14ce8e..841027b175 100644
--- a/activerecord/test/default_test_firebird.rb
+++ b/activerecord/test/default_test_firebird.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/default'
-class DefaultTest < Test::Unit::TestCase
+class DefaultTest < ActiveSupport::TestCase
def test_default_timestamp
default = Default.new
assert_instance_of(Time, default.default_timestamp)
diff --git a/activerecord/test/defaults_test.rb b/activerecord/test/defaults_test.rb
index 9701d1a8af..8a5c8e0530 100644
--- a/activerecord/test/defaults_test.rb
+++ b/activerecord/test/defaults_test.rb
@@ -2,7 +2,7 @@ require 'abstract_unit'
require 'fixtures/default'
require 'fixtures/entrant'
-class DefaultTest < Test::Unit::TestCase
+class DefaultTest < ActiveSupport::TestCase
def test_nil_defaults_for_not_null_columns
column_defaults =
if current_adapter?(:MysqlAdapter)
diff --git a/activerecord/test/deprecated_finder_test.rb b/activerecord/test/deprecated_finder_test.rb
index 097c9131dc..9c5a74cf02 100755
--- a/activerecord/test/deprecated_finder_test.rb
+++ b/activerecord/test/deprecated_finder_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/entrant'
-class DeprecatedFinderTest < Test::Unit::TestCase
+class DeprecatedFinderTest < ActiveSupport::TestCase
fixtures :entrants
def test_deprecated_find_all_was_removed
diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb
index 13cac2ac22..c0484d9e78 100644
--- a/activerecord/test/finder_test.rb
+++ b/activerecord/test/finder_test.rb
@@ -8,7 +8,7 @@ require 'fixtures/entrant'
require 'fixtures/developer'
require 'fixtures/post'
-class FinderTest < Test::Unit::TestCase
+class FinderTest < ActiveSupport::TestCase
fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :comments, :accounts, :authors
def test_find
diff --git a/activerecord/test/fixtures_test.rb b/activerecord/test/fixtures_test.rb
index 79023ac838..bbc3e1e5a4 100755
--- a/activerecord/test/fixtures_test.rb
+++ b/activerecord/test/fixtures_test.rb
@@ -16,7 +16,7 @@ require 'fixtures/treasure'
require 'fixtures/matey'
require 'fixtures/ship'
-class FixturesTest < Test::Unit::TestCase
+class FixturesTest < ActiveSupport::TestCase
self.use_instantiated_fixtures = true
self.use_transactional_fixtures = false
@@ -204,7 +204,7 @@ class FixturesTest < Test::Unit::TestCase
end
if Account.connection.respond_to?(:reset_pk_sequence!)
- class FixturesResetPkSequenceTest < Test::Unit::TestCase
+ class FixturesResetPkSequenceTest < ActiveSupport::TestCase
fixtures :accounts
fixtures :companies
@@ -250,7 +250,7 @@ if Account.connection.respond_to?(:reset_pk_sequence!)
end
end
-class FixturesWithoutInstantiationTest < Test::Unit::TestCase
+class FixturesWithoutInstantiationTest < ActiveSupport::TestCase
self.use_instantiated_fixtures = false
fixtures :topics, :developers, :accounts
@@ -285,7 +285,7 @@ class FixturesWithoutInstantiationTest < Test::Unit::TestCase
end
end
-class FixturesWithoutInstanceInstantiationTest < Test::Unit::TestCase
+class FixturesWithoutInstanceInstantiationTest < ActiveSupport::TestCase
self.use_instantiated_fixtures = true
self.use_instantiated_fixtures = :no_instances
@@ -299,7 +299,7 @@ class FixturesWithoutInstanceInstantiationTest < Test::Unit::TestCase
end
end
-class TransactionalFixturesTest < Test::Unit::TestCase
+class TransactionalFixturesTest < ActiveSupport::TestCase
self.use_instantiated_fixtures = true
self.use_transactional_fixtures = true
@@ -315,7 +315,7 @@ class TransactionalFixturesTest < Test::Unit::TestCase
end
end
-class MultipleFixturesTest < Test::Unit::TestCase
+class MultipleFixturesTest < ActiveSupport::TestCase
fixtures :topics
fixtures :developers, :accounts
@@ -324,7 +324,7 @@ class MultipleFixturesTest < Test::Unit::TestCase
end
end
-class SetupTest < Test::Unit::TestCase
+class SetupTest < ActiveSupport::TestCase
# fixtures :topics
def setup
@@ -348,7 +348,7 @@ class SetupSubclassTest < SetupTest
end
-class OverlappingFixturesTest < Test::Unit::TestCase
+class OverlappingFixturesTest < ActiveSupport::TestCase
fixtures :topics, :developers
fixtures :developers, :accounts
@@ -357,7 +357,7 @@ class OverlappingFixturesTest < Test::Unit::TestCase
end
end
-class ForeignKeyFixturesTest < Test::Unit::TestCase
+class ForeignKeyFixturesTest < ActiveSupport::TestCase
fixtures :fk_test_has_pk, :fk_test_has_fk
# if foreign keys are implemented and fixtures
@@ -373,7 +373,7 @@ class ForeignKeyFixturesTest < Test::Unit::TestCase
end
end
-class SetTableNameFixturesTest < Test::Unit::TestCase
+class SetTableNameFixturesTest < ActiveSupport::TestCase
set_fixture_class :funny_jokes => 'Joke'
fixtures :funny_jokes
@@ -382,7 +382,7 @@ class SetTableNameFixturesTest < Test::Unit::TestCase
end
end
-class CustomConnectionFixturesTest < Test::Unit::TestCase
+class CustomConnectionFixturesTest < ActiveSupport::TestCase
set_fixture_class :courses => Course
fixtures :courses
@@ -392,7 +392,7 @@ class CustomConnectionFixturesTest < Test::Unit::TestCase
end
end
-class InvalidTableNameFixturesTest < Test::Unit::TestCase
+class InvalidTableNameFixturesTest < ActiveSupport::TestCase
fixtures :funny_jokes
def test_raises_error
@@ -402,7 +402,7 @@ class InvalidTableNameFixturesTest < Test::Unit::TestCase
end
end
-class CheckEscapedYamlFixturesTest < Test::Unit::TestCase
+class CheckEscapedYamlFixturesTest < ActiveSupport::TestCase
set_fixture_class :funny_jokes => 'Joke'
fixtures :funny_jokes
@@ -412,7 +412,7 @@ class CheckEscapedYamlFixturesTest < Test::Unit::TestCase
end
class DevelopersProject; end
-class ManyToManyFixturesWithClassDefined < Test::Unit::TestCase
+class ManyToManyFixturesWithClassDefined < ActiveSupport::TestCase
fixtures :developers_projects
def test_this_should_run_cleanly
@@ -420,22 +420,22 @@ class ManyToManyFixturesWithClassDefined < Test::Unit::TestCase
end
end
-class FixturesBrokenRollbackTest < Test::Unit::TestCase
+class FixturesBrokenRollbackTest < ActiveSupport::TestCase
def blank_setup; end
- alias_method :ar_setup_with_fixtures, :setup_with_fixtures
- alias_method :setup_with_fixtures, :blank_setup
+ alias_method :ar_setup_fixtures, :setup_fixtures
+ alias_method :setup_fixtures, :blank_setup
alias_method :setup, :blank_setup
def blank_teardown; end
- alias_method :ar_teardown_with_fixtures, :teardown_with_fixtures
- alias_method :teardown_with_fixtures, :blank_teardown
+ alias_method :ar_teardown_fixtures, :teardown_fixtures
+ alias_method :teardown_fixtures, :blank_teardown
alias_method :teardown, :blank_teardown
def test_no_rollback_in_teardown_unless_transaction_active
assert_equal 0, Thread.current['open_transactions']
- assert_raise(RuntimeError) { ar_setup_with_fixtures }
+ assert_raise(RuntimeError) { ar_setup_fixtures }
assert_equal 0, Thread.current['open_transactions']
- assert_nothing_raised { ar_teardown_with_fixtures }
+ assert_nothing_raised { ar_teardown_fixtures }
assert_equal 0, Thread.current['open_transactions']
end
@@ -445,7 +445,7 @@ class FixturesBrokenRollbackTest < Test::Unit::TestCase
end
end
-class LoadAllFixturesTest < Test::Unit::TestCase
+class LoadAllFixturesTest < ActiveSupport::TestCase
self.fixture_path= File.join(File.dirname(__FILE__), '/fixtures/all')
fixtures :all
@@ -454,7 +454,7 @@ class LoadAllFixturesTest < Test::Unit::TestCase
end
end
-class FasterFixturesTest < Test::Unit::TestCase
+class FasterFixturesTest < ActiveSupport::TestCase
fixtures :categories, :authors
def load_extra_fixture(name)
@@ -479,7 +479,7 @@ class FasterFixturesTest < Test::Unit::TestCase
end
end
-class FoxyFixturesTest < Test::Unit::TestCase
+class FoxyFixturesTest < ActiveSupport::TestCase
fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers, :developers
def test_identifies_strings
diff --git a/activerecord/test/inheritance_test.rb b/activerecord/test/inheritance_test.rb
index 2d0a834ba1..0bba53de43 100755
--- a/activerecord/test/inheritance_test.rb
+++ b/activerecord/test/inheritance_test.rb
@@ -3,7 +3,7 @@ require 'fixtures/company'
require 'fixtures/project'
require 'fixtures/subscriber'
-class InheritanceTest < Test::Unit::TestCase
+class InheritanceTest < ActiveSupport::TestCase
fixtures :companies, :projects, :subscribers, :accounts
def test_company_descends_from_active_record
@@ -175,7 +175,7 @@ class InheritanceTest < Test::Unit::TestCase
end
-class InheritanceComputeTypeTest < Test::Unit::TestCase
+class InheritanceComputeTypeTest < ActiveSupport::TestCase
fixtures :companies
def setup
diff --git a/activerecord/test/json_serialization_test.rb b/activerecord/test/json_serialization_test.rb
index 5aeb24b25d..49711f625b 100644
--- a/activerecord/test/json_serialization_test.rb
+++ b/activerecord/test/json_serialization_test.rb
@@ -6,7 +6,7 @@ require 'fixtures/tagging'
require 'fixtures/tag'
require 'fixtures/comment'
-class JsonSerializationTest < Test::Unit::TestCase
+class JsonSerializationTest < ActiveSupport::TestCase
def setup
@contact = Contact.new(
:name => 'Konata Izumi',
@@ -63,7 +63,7 @@ class JsonSerializationTest < Test::Unit::TestCase
end
end
-class DatabaseConnectedJsonEncodingTest < Test::Unit::TestCase
+class DatabaseConnectedJsonEncodingTest < ActiveSupport::TestCase
fixtures :authors, :posts, :comments, :tags, :taggings
def setup
diff --git a/activerecord/test/lifecycle_test.rb b/activerecord/test/lifecycle_test.rb
index 5f9e12a7e2..43a798525d 100755
--- a/activerecord/test/lifecycle_test.rb
+++ b/activerecord/test/lifecycle_test.rb
@@ -64,7 +64,7 @@ class MultiObserver < ActiveRecord::Observer
end
end
-class LifecycleTest < Test::Unit::TestCase
+class LifecycleTest < ActiveSupport::TestCase
fixtures :topics, :developers
def test_before_destroy
diff --git a/activerecord/test/locking_test.rb b/activerecord/test/locking_test.rb
index 9a3b76e810..95bd517e76 100644
--- a/activerecord/test/locking_test.rb
+++ b/activerecord/test/locking_test.rb
@@ -14,7 +14,7 @@ class ReadonlyFirstNamePerson < Person
attr_readonly :first_name
end
-class OptimisticLockingTest < Test::Unit::TestCase
+class OptimisticLockingTest < ActiveSupport::TestCase
fixtures :people, :legacy_things
# need to disable transactional fixtures, because otherwise the sqlite3
@@ -176,7 +176,7 @@ end
# TODO: The SQL Server, Sybase, and OpenBase adapters currently have no support for pessimistic locking
unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :OpenBaseAdapter)
- class PessimisticLockingTest < Test::Unit::TestCase
+ class PessimisticLockingTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
fixtures :people, :readers
diff --git a/activerecord/test/method_scoping_test.rb b/activerecord/test/method_scoping_test.rb
index ee4a52df1d..655308f4a2 100644
--- a/activerecord/test/method_scoping_test.rb
+++ b/activerecord/test/method_scoping_test.rb
@@ -5,7 +5,7 @@ require 'fixtures/comment'
require 'fixtures/post'
require 'fixtures/category'
-class MethodScopingTest < Test::Unit::TestCase
+class MethodScopingTest < ActiveSupport::TestCase
fixtures :developers, :projects, :comments, :posts
def test_set_conditions
@@ -125,7 +125,7 @@ class MethodScopingTest < Test::Unit::TestCase
end
end
-class NestedScopingTest < Test::Unit::TestCase
+class NestedScopingTest < ActiveSupport::TestCase
fixtures :developers, :projects, :comments, :posts
def test_merge_options
@@ -313,7 +313,7 @@ class NestedScopingTest < Test::Unit::TestCase
end
end
-class HasManyScopingTest< Test::Unit::TestCase
+class HasManyScopingTest< ActiveSupport::TestCase
fixtures :comments, :posts
def setup
@@ -343,7 +343,7 @@ class HasManyScopingTest< Test::Unit::TestCase
end
-class HasAndBelongsToManyScopingTest< Test::Unit::TestCase
+class HasAndBelongsToManyScopingTest< ActiveSupport::TestCase
fixtures :posts, :categories, :categories_posts
def setup
@@ -373,7 +373,7 @@ end
# We disabled the scoping for has_one and belongs_to as we can't think of a proper use case
-class BelongsToScopingTest< Test::Unit::TestCase
+class BelongsToScopingTest< ActiveSupport::TestCase
fixtures :comments, :posts
def setup
@@ -393,7 +393,7 @@ class BelongsToScopingTest< Test::Unit::TestCase
end
-class HasOneScopingTest< Test::Unit::TestCase
+class HasOneScopingTest< ActiveSupport::TestCase
fixtures :comments, :posts
def setup
diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb
index 0113cc1796..3b74604c44 100644
--- a/activerecord/test/migration_test.rb
+++ b/activerecord/test/migration_test.rb
@@ -22,7 +22,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end
end
- class MigrationTest < Test::Unit::TestCase
+ class MigrationTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
fixtures :people
@@ -909,7 +909,7 @@ if ActiveRecord::Base.connection.supports_migrations?
end
uses_mocha 'Sexy migration tests' do
- class SexyMigrationsTest < Test::Unit::TestCase
+ class SexyMigrationsTest < ActiveSupport::TestCase
def test_references_column_type_adds_id
with_new_table do |t|
t.expects(:column).with('customer_id', :integer, {})
diff --git a/activerecord/test/migration_test_firebird.rb b/activerecord/test/migration_test_firebird.rb
index 92d531b75b..5c7dbd7a35 100644
--- a/activerecord/test/migration_test_firebird.rb
+++ b/activerecord/test/migration_test_firebird.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/course'
-class FirebirdMigrationTest < Test::Unit::TestCase
+class FirebirdMigrationTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
def setup
diff --git a/activerecord/test/mixin_test.rb b/activerecord/test/mixin_test.rb
index d2118e6764..1bf8764d7e 100644
--- a/activerecord/test/mixin_test.rb
+++ b/activerecord/test/mixin_test.rb
@@ -21,7 +21,7 @@ class Time
end
-class TouchTest < Test::Unit::TestCase
+class TouchTest < ActiveSupport::TestCase
fixtures :mixins
def setup
diff --git a/activerecord/test/modules_test.rb b/activerecord/test/modules_test.rb
index f915102eb0..7e4d0f10bc 100644
--- a/activerecord/test/modules_test.rb
+++ b/activerecord/test/modules_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/company_in_module'
-class ModulesTest < Test::Unit::TestCase
+class ModulesTest < ActiveSupport::TestCase
fixtures :accounts, :companies, :projects, :developers
def test_module_spanning_associations
diff --git a/activerecord/test/multiple_db_test.rb b/activerecord/test/multiple_db_test.rb
index f0fcc92fd4..5d64a3efaa 100644
--- a/activerecord/test/multiple_db_test.rb
+++ b/activerecord/test/multiple_db_test.rb
@@ -4,7 +4,7 @@ require 'fixtures/entrant'
# So we can test whether Course.connection survives a reload.
require_dependency 'fixtures/course'
-class MultipleDbTest < Test::Unit::TestCase
+class MultipleDbTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
def setup
diff --git a/activerecord/test/pk_test.rb b/activerecord/test/pk_test.rb
index 431ff9af9d..9566fc646d 100644
--- a/activerecord/test/pk_test.rb
+++ b/activerecord/test/pk_test.rb
@@ -6,7 +6,7 @@ require 'fixtures/movie'
require 'fixtures/keyboard'
require 'fixtures/mixed_case_monkey'
-class PrimaryKeysTest < Test::Unit::TestCase
+class PrimaryKeysTest < ActiveSupport::TestCase
fixtures :topics, :subscribers, :movies, :mixed_case_monkeys
def test_integer_key
diff --git a/activerecord/test/query_cache_test.rb b/activerecord/test/query_cache_test.rb
index 08a492153c..12b52f6a35 100644
--- a/activerecord/test/query_cache_test.rb
+++ b/activerecord/test/query_cache_test.rb
@@ -5,7 +5,7 @@ require 'fixtures/task'
require 'fixtures/course'
-class QueryCacheTest < Test::Unit::TestCase
+class QueryCacheTest < ActiveSupport::TestCase
fixtures :tasks, :topics
def test_find_queries
@@ -55,7 +55,7 @@ end
uses_mocha 'QueryCacheExpiryTest' do
-class QueryCacheExpiryTest < Test::Unit::TestCase
+class QueryCacheExpiryTest < ActiveSupport::TestCase
fixtures :tasks
def test_find
diff --git a/activerecord/test/readonly_test.rb b/activerecord/test/readonly_test.rb
index 584eb735fe..6bac42e468 100755
--- a/activerecord/test/readonly_test.rb
+++ b/activerecord/test/readonly_test.rb
@@ -11,7 +11,7 @@ def Comment.foo() find :first end
def Project.foo() find :first end
-class ReadOnlyTest < Test::Unit::TestCase
+class ReadOnlyTest < ActiveSupport::TestCase
fixtures :posts, :comments, :developers, :projects, :developers_projects
def test_cant_save_readonly_record
diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/reflection_test.rb
index 1ed5c2610c..a2dab89732 100644
--- a/activerecord/test/reflection_test.rb
+++ b/activerecord/test/reflection_test.rb
@@ -5,7 +5,7 @@ require 'fixtures/company'
require 'fixtures/company_in_module'
require 'fixtures/subscriber'
-class ReflectionTest < Test::Unit::TestCase
+class ReflectionTest < ActiveSupport::TestCase
fixtures :topics, :customers, :companies, :subscribers
def setup
diff --git a/activerecord/test/reserved_word_test_mysql.rb b/activerecord/test/reserved_word_test_mysql.rb
index 10a9fca11e..58398f04e2 100644
--- a/activerecord/test/reserved_word_test_mysql.rb
+++ b/activerecord/test/reserved_word_test_mysql.rb
@@ -23,7 +23,7 @@ end
# a suite of tests to ensure the ConnectionAdapters#MysqlAdapter can handle tables with
# reserved word names (ie: group, order, values, etc...)
-class MysqlReservedWordTest < Test::Unit::TestCase
+class MysqlReservedWordTest < ActiveSupport::TestCase
def setup
@connection = ActiveRecord::Base.connection
diff --git a/activerecord/test/schema_authorization_test_postgresql.rb b/activerecord/test/schema_authorization_test_postgresql.rb
index f13287658c..89044deb16 100644
--- a/activerecord/test/schema_authorization_test_postgresql.rb
+++ b/activerecord/test/schema_authorization_test_postgresql.rb
@@ -3,7 +3,7 @@ require 'abstract_unit'
class SchemaThing < ActiveRecord::Base
end
-class SchemaAuthorizationTest < Test::Unit::TestCase
+class SchemaAuthorizationTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
TABLE_NAME = 'schema_things'
diff --git a/activerecord/test/schema_dumper_test.rb b/activerecord/test/schema_dumper_test.rb
index c6041e4f5c..390181af8e 100644
--- a/activerecord/test/schema_dumper_test.rb
+++ b/activerecord/test/schema_dumper_test.rb
@@ -4,7 +4,7 @@ require 'stringio'
if ActiveRecord::Base.connection.respond_to?(:tables)
- class SchemaDumperTest < Test::Unit::TestCase
+ class SchemaDumperTest < ActiveSupport::TestCase
def standard_dump
stream = StringIO.new
ActiveRecord::SchemaDumper.ignore_tables = []
diff --git a/activerecord/test/schema_test_postgresql.rb b/activerecord/test/schema_test_postgresql.rb
index c743a86195..c38d6c9253 100644
--- a/activerecord/test/schema_test_postgresql.rb
+++ b/activerecord/test/schema_test_postgresql.rb
@@ -1,6 +1,6 @@
require 'abstract_unit'
-class SchemaTest < Test::Unit::TestCase
+class SchemaTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
SCHEMA_NAME = 'test_schema'
diff --git a/activerecord/test/serialization_test.rb b/activerecord/test/serialization_test.rb
index a8295da26a..61756999ed 100644
--- a/activerecord/test/serialization_test.rb
+++ b/activerecord/test/serialization_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'fixtures/contact'
-class SerializationTest < Test::Unit::TestCase
+class SerializationTest < ActiveSupport::TestCase
FORMATS = [ :xml, :json ]
def setup
diff --git a/activerecord/test/synonym_test_oracle.rb b/activerecord/test/synonym_test_oracle.rb
index fcfb2f3bd1..2eff36b097 100644
--- a/activerecord/test/synonym_test_oracle.rb
+++ b/activerecord/test/synonym_test_oracle.rb
@@ -6,7 +6,7 @@ require 'fixtures/subject'
# the "subjects" table in Oracle (defined in oci.sql) is just
# a synonym to the "topics" table
-class TestOracleSynonym < Test::Unit::TestCase
+class TestOracleSynonym < ActiveSupport::TestCase
def test_oracle_synonym
topic = Topic.new
diff --git a/activerecord/test/table_name_test_sqlserver.rb b/activerecord/test/table_name_test_sqlserver.rb
index c2d1711599..f52a3da5fb 100644
--- a/activerecord/test/table_name_test_sqlserver.rb
+++ b/activerecord/test/table_name_test_sqlserver.rb
@@ -6,7 +6,7 @@ if ActiveRecord::Base.connection.supports_migrations?
self.table_name = '[order]'
end
- class TableNameTest < Test::Unit::TestCase
+ class TableNameTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
# Ensures Model.columns works when using SQLServer escape characters.
diff --git a/activerecord/test/threaded_connections_test.rb b/activerecord/test/threaded_connections_test.rb
index aaa56b3bfe..85cb1d5154 100644
--- a/activerecord/test/threaded_connections_test.rb
+++ b/activerecord/test/threaded_connections_test.rb
@@ -3,7 +3,7 @@ require 'fixtures/topic'
require 'fixtures/reply'
unless %w(FrontBase).include? ActiveRecord::Base.connection.adapter_name
- class ThreadedConnectionsTest < Test::Unit::TestCase
+ class ThreadedConnectionsTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
fixtures :topics
diff --git a/activerecord/test/transactions_test.rb b/activerecord/test/transactions_test.rb
index a31d993dbb..f36ee3f4bb 100644
--- a/activerecord/test/transactions_test.rb
+++ b/activerecord/test/transactions_test.rb
@@ -3,7 +3,7 @@ require 'fixtures/topic'
require 'fixtures/reply'
require 'fixtures/developer'
-class TransactionTest < Test::Unit::TestCase
+class TransactionTest < ActiveSupport::TestCase
self.use_transactional_fixtures = false
fixtures :topics, :developers
diff --git a/activerecord/test/unconnected_test.rb b/activerecord/test/unconnected_test.rb
index 8079a051e5..6f475f8364 100755
--- a/activerecord/test/unconnected_test.rb
+++ b/activerecord/test/unconnected_test.rb
@@ -3,7 +3,7 @@ require 'abstract_unit'
class TestRecord < ActiveRecord::Base
end
-class TestUnconnectedAdapter < Test::Unit::TestCase
+class TestUnconnectedAdapter < ActiveSupport::TestCase
self.use_transactional_fixtures = false
def setup
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb
index bbae598f2d..c4f6f2d6b1 100755
--- a/activerecord/test/validations_test.rb
+++ b/activerecord/test/validations_test.rb
@@ -53,7 +53,7 @@ end
class Thaumaturgist < IneptWizard
end
-class ValidationsTest < Test::Unit::TestCase
+class ValidationsTest < ActiveSupport::TestCase
fixtures :topics, :developers
def setup
@@ -1273,7 +1273,7 @@ class ValidationsTest < Test::Unit::TestCase
end
-class ValidatesNumericalityTest < Test::Unit::TestCase
+class ValidatesNumericalityTest < ActiveSupport::TestCase
NIL = [nil]
BLANK = ["", " ", " \t \r \n"]
BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significent digits
diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/xml_serialization_test.rb
index 9b74ddd45b..2db75fad46 100644
--- a/activerecord/test/xml_serialization_test.rb
+++ b/activerecord/test/xml_serialization_test.rb
@@ -5,7 +5,7 @@ require 'fixtures/author'
require 'fixtures/tagging'
require 'fixtures/comment'
-class XmlSerializationTest < Test::Unit::TestCase
+class XmlSerializationTest < ActiveSupport::TestCase
def test_should_serialize_default_root
@xml = Contact.new.to_xml
assert_match %r{^<contact>}, @xml
@@ -40,7 +40,7 @@ class XmlSerializationTest < Test::Unit::TestCase
end
end
-class DefaultXmlSerializationTest < Test::Unit::TestCase
+class DefaultXmlSerializationTest < ActiveSupport::TestCase
def setup
@xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false, :preferences => { :gem => 'ruby' }).to_xml
end
@@ -72,7 +72,7 @@ class DefaultXmlSerializationTest < Test::Unit::TestCase
end
end
-class NilXmlSerializationTest < Test::Unit::TestCase
+class NilXmlSerializationTest < ActiveSupport::TestCase
def setup
@xml = Contact.new.to_xml(:root => 'xml_contact')
end
@@ -118,7 +118,7 @@ class NilXmlSerializationTest < Test::Unit::TestCase
end
end
-class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase
+class DatabaseConnectedXmlSerializationTest < ActiveSupport::TestCase
fixtures :authors, :posts
# to_xml used to mess with the hash the user provided which
# caused the builder to be reused. This meant the document kept
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 16296a579f..a4a605c782 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,9 @@
*SVN*
+* Continue evolution toward ActiveSupport::TestCase. #10679 [Josh Peek]
+
+* TestCase: introduce declared setup and teardown callbacks. Pass a list of methods and an optional block to call before setup or after teardown. Setup callbacks are run in the order declared; teardown callbacks are run in reverse. [Jeremy Kemper]
+
* Added ActiveSupport::Gzip.decompress/compress(source) as an easy wrapper for Zlib [Tobias Luetke]
* Included MemCache-Client to make the improved ActiveSupport::Cache::MemCacheStore work out of the box [Bob Cottrell, Eric Hodel]
diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb
index c459511dc8..c4b7cc8cba 100644
--- a/activesupport/lib/active_support.rb
+++ b/activesupport/lib/active_support.rb
@@ -49,6 +49,3 @@ require 'active_support/json'
require 'active_support/multibyte'
require 'active_support/base64'
-
-require 'active_support/testing'
-
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index be8f8b17fc..67cde1556c 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -1,5 +1,13 @@
+require 'test/unit/testcase'
+require 'active_support/testing/setup_and_teardown'
+require 'active_support/testing/default'
+
+# TODO: move to core_ext
+class Test::Unit::TestCase #:nodoc:
+ include ActiveSupport::Testing::SetupAndTeardown
+end
+
module ActiveSupport
class TestCase < Test::Unit::TestCase
- include ActiveSupport::Testing::Default
end
-end \ No newline at end of file
+end
diff --git a/activesupport/lib/active_support/testing.rb b/activesupport/lib/active_support/testing.rb
deleted file mode 100644
index 1bf30cbbdd..0000000000
--- a/activesupport/lib/active_support/testing.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'active_support/testing/default' \ No newline at end of file
diff --git a/activesupport/lib/active_support/testing/default.rb b/activesupport/lib/active_support/testing/default.rb
index d97a610c79..a0bd6303c7 100644
--- a/activesupport/lib/active_support/testing/default.rb
+++ b/activesupport/lib/active_support/testing/default.rb
@@ -1,12 +1,9 @@
module ActiveSupport
module Testing
- module Default
- def run(*args)
- #method_name appears to be a symbol on 1.8.4 and a string on 1.8.6
- return if @method_name.to_s == "default_test"
- super
+ module Default #:nodoc:
+ # Placeholder so test/unit ignores test cases without any tests.
+ def default_test
end
end
end
end
-
diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb
new file mode 100644
index 0000000000..1639462fae
--- /dev/null
+++ b/activesupport/lib/active_support/testing/setup_and_teardown.rb
@@ -0,0 +1,127 @@
+module ActiveSupport
+ module Testing
+ module SetupAndTeardown
+ def self.included(base)
+ base.extend ClassMethods
+
+ begin
+ require 'mocha'
+ base.alias_method_chain :run, :callbacks_and_mocha
+ rescue LoadError
+ base.alias_method_chain :run, :callbacks
+ end
+ end
+
+ module ClassMethods
+ def setup(*method_names, &block)
+ method_names << block if block_given?
+ (@setup_callbacks ||= []).concat method_names
+ end
+
+ def teardown(*method_names, &block)
+ method_names << block if block_given?
+ (@teardown_callbacks ||= []).concat method_names
+ end
+
+ def setup_callback_chain
+ @setup_callbacks ||= []
+
+ if superclass.respond_to?(:setup_callback_chain)
+ superclass.setup_callback_chain + @setup_callbacks
+ else
+ @setup_callbacks
+ end
+ end
+
+ def teardown_callback_chain
+ @teardown_callbacks ||= []
+
+ if superclass.respond_to?(:teardown_callback_chain)
+ superclass.teardown_callback_chain + @teardown_callbacks
+ else
+ @teardown_callbacks
+ end
+ end
+ end
+
+ # This redefinition is unfortunate but test/unit shows us no alternative.
+ def run_with_callbacks(result) #:nodoc:
+ return if @method_name.to_s == "default_test"
+
+ yield(Test::Unit::TestCase::STARTED, name)
+ @_result = result
+ begin
+ run_callbacks :setup
+ setup
+ __send__(@method_name)
+ rescue Test::Unit::AssertionFailedError => e
+ add_failure(e.message, e.backtrace)
+ rescue *Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
+ raise
+ rescue Exception
+ add_error($!)
+ ensure
+ begin
+ teardown
+ run_callbacks :teardown, :reverse_each
+ rescue Test::Unit::AssertionFailedError => e
+ add_failure(e.message, e.backtrace)
+ rescue *Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
+ raise
+ rescue Exception
+ add_error($!)
+ end
+ end
+ result.add_run
+ yield(Test::Unit::TestCase::FINISHED, name)
+ end
+
+ # Doubly unfortunate: mocha does the same so we have to hax their hax.
+ def run_with_callbacks_and_mocha(result)
+ return if @method_name.to_s == "default_test"
+
+ yield(Test::Unit::TestCase::STARTED, name)
+ @_result = result
+ begin
+ mocha_setup
+ begin
+ run_callbacks :setup
+ setup
+ __send__(@method_name)
+ mocha_verify { add_assertion }
+ rescue Mocha::ExpectationError => e
+ add_failure(e.message, e.backtrace)
+ rescue Test::Unit::AssertionFailedError => e
+ add_failure(e.message, e.backtrace)
+ rescue StandardError, ScriptError
+ add_error($!)
+ ensure
+ begin
+ teardown
+ run_callbacks :teardown, :reverse_each
+ rescue Test::Unit::AssertionFailedError => e
+ add_failure(e.message, e.backtrace)
+ rescue StandardError, ScriptError
+ add_error($!)
+ end
+ end
+ ensure
+ mocha_teardown
+ end
+ result.add_run
+ yield(Test::Unit::TestCase::FINISHED, name)
+ end
+
+ protected
+ def run_callbacks(kind, enumerator = :each)
+ self.class.send("#{kind}_callback_chain").send(enumerator) do |callback|
+ case callback
+ when Proc; callback.call(self)
+ when String, Symbol; send!(callback)
+ else raise ArgumentError, "Unrecognized callback #{callback.inspect}"
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/activesupport/test/core_ext/load_error_tests.rb b/activesupport/test/core_ext/load_error_test.rb
index 34c5cb4cda..5bb5b4d1b8 100644
--- a/activesupport/test/core_ext/load_error_tests.rb
+++ b/activesupport/test/core_ext/load_error_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../abstract_unit'
+require 'abstract_unit'
class TestMissingSourceFile < Test::Unit::TestCase
def test_with_require
diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb
index 9ac54db69b..88b505e59c 100644
--- a/activesupport/test/test_test.rb
+++ b/activesupport/test/test_test.rb
@@ -72,3 +72,49 @@ end
class AlsoDoingNothingTest < ActiveSupport::TestCase
end
+
+# Setup and teardown callbacks.
+class SetupAndTeardownTest < Test::Unit::TestCase
+ setup :reset_callback_record, :foo
+ teardown :foo, :sentinel, :foo
+
+ def test_inherited_setup_callbacks
+ assert_equal [:reset_callback_record, :foo], self.class.setup_callback_chain
+ assert_equal [:foo], @called_back
+ assert_equal [:foo, :sentinel, :foo], self.class.teardown_callback_chain
+ end
+
+ protected
+ def reset_callback_record
+ @called_back = []
+ end
+
+ def foo
+ @called_back << :foo
+ end
+
+ def sentinel
+ assert_equal [:foo, :foo], @called_back
+ end
+end
+
+
+class SubclassSetupAndTeardownTest < SetupAndTeardownTest
+ setup :bar
+ teardown :bar
+
+ def test_inherited_setup_callbacks
+ assert_equal [:reset_callback_record, :foo, :bar], self.class.setup_callback_chain
+ assert_equal [:foo, :bar], @called_back
+ assert_equal [:foo, :sentinel, :foo, :bar], self.class.teardown_callback_chain
+ end
+
+ protected
+ def bar
+ @called_back << :bar
+ end
+
+ def sentinel
+ assert_equal [:foo, :bar, :bar, :foo], @called_back
+ end
+end