public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
* Continue evolution toward ActiveSupport::TestCase and friends.  #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]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8570 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jeremy (author)
Sat Jan 05 05:34:15 -0800 2008
commit  139b92495fa7697cdd619c549d4c7b263562b761
tree    20589f9f23d3b19697fed12bb1bf5ce48ef595af
parent  fe66397adfb5a8057db78afcabd4d7eb0f13a783
...
8
9
10
11
12
 
13
14
15
 
 
 
16
17
18
...
33
34
35
36
37
38
39
40
41
42
43
44
45
 
 
 
 
 
 
46
47
48
49
50
51
52
53
54
55
 
 
 
 
56
57
58
59
60
...
8
9
10
 
 
11
12
13
14
15
16
17
18
19
20
...
35
36
37
 
 
 
 
 
 
 
 
 
 
38
39
40
41
42
43
44
 
 
 
 
 
 
 
 
 
45
46
47
48
49
 
50
51
52
0
@@ -8,11 +8,13 @@ module ActionMailer
0
         "test case definition"
0
     end
0
   end
0
-  # New Test Super class for forward compatibility.
0
-  # To override
0
+
0
   class TestCase < ActiveSupport::TestCase
0
     include ActionMailer::Quoting
0
 
0
+    setup :initialize_test_deliveries
0
+    setup :set_expected_mail
0
+
0
     class << self
0
       def tests(mailer)
0
         write_inheritable_attribute(:mailer_class, mailer)
0
@@ -33,28 +35,18 @@ module ActionMailer
0
       end
0
     end
0
 
0
-    def setup_with_mailer
0
-      ActionMailer::Base.delivery_method = :test
0
-      ActionMailer::Base.perform_deliveries = true
0
-      ActionMailer::Base.deliveries = []
0
-
0
-      @expected = TMail::Mail.new
0
-      @expected.set_content_type "text", "plain", { "charset" => charset }
0
-      @expected.mime_version = '1.0'
0
-    end
0
-    alias_method :setup, :setup_with_mailer
0
+    protected
0
+      def initialize_test_deliveries
0
+        ActionMailer::Base.delivery_method = :test
0
+        ActionMailer::Base.perform_deliveries = true
0
+        ActionMailer::Base.deliveries = []
0
+      end
0
 
0
-    def self.method_added(method)
0
-      if method.to_s == 'setup'
0
-        unless method_defined?(:setup_without_mailer)
0
-          alias_method :setup_without_mailer, :setup
0
-          define_method(:setup) do
0
-            setup_with_mailer
0
-            setup_without_mailer
0
-          end
0
-        end
0
+      def set_expected_mail
0
+        @expected = TMail::Mail.new
0
+        @expected.set_content_type "text", "plain", { "charset" => charset }
0
+        @expected.mime_version = '1.0'
0
       end
0
-    end
0
 
0
     private
0
       def charset
...
9
10
11
12
13
14
15
...
117
118
119
120
121
122
123
124
125
126
127
128
 
129
130
131
132
133
 
134
135
...
9
10
11
 
12
13
14
...
116
117
118
 
119
120
121
 
122
123
124
 
125
126
 
 
 
 
127
128
129
0
@@ -9,7 +9,6 @@ class TestHelperMailer < ActionMailer::Base
0
 end
0
 
0
 class TestHelperMailerTest < ActionMailer::TestCase
0
-
0
   def test_setup_sets_right_action_mailer_options
0
     assert_equal :test, ActionMailer::Base.delivery_method
0
     assert ActionMailer::Base.perform_deliveries
0
@@ -117,19 +116,14 @@ class TestHelperMailerTest < ActionMailer::TestCase
0
 end
0
 
0
 class AnotherTestHelperMailerTest < ActionMailer::TestCase
0
-
0
   tests TestHelperMailer
0
 
0
   def setup
0
-    # Should not override ActionMailer setup methods
0
     @test_var = "a value"
0
   end
0
 
0
-  def test_should_still_setup_mailer
0
+  def test_setup_shouldnt_conflict_with_mailer_setup
0
     assert @expected.is_a?(TMail::Mail)
0
-  end
0
-  
0
-  def test_should_run_overridden_setup_method
0
-    assert @test_var
0
+    assert_equal 'a value', @test_var
0
   end
0
 end
...
10
11
12
 
 
 
 
 
 
 
 
13
 
14
15
16
...
25
26
27
28
 
29
30
31
...
36
37
38
39
40
41
42
43
 
44
45
46
47
 
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
34
35
36
 
37
38
39
40
...
45
46
47
 
 
 
 
 
48
49
50
51
 
52
53
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
 
57
58
0
@@ -10,7 +10,16 @@ module ActionController
0
   end
0
 
0
   class TestCase < ActiveSupport::TestCase
0
+    module RaiseActionExceptions
0
+      def rescue_action(e)
0
+        raise e
0
+      end
0
+    end
0
+
0
+    setup :setup_controller_request_and_response
0
+
0
     @@controller_class = nil
0
+
0
     class << self
0
       def tests(controller_class)
0
         self.controller_class = controller_class
0
@@ -25,7 +34,7 @@ module ActionController
0
         if current_controller_class = read_inheritable_attribute(:controller_class)
0
           current_controller_class
0
         else
0
-          self.controller_class= determine_default_controller_class(name)
0
+          self.controller_class = determine_default_controller_class(name)
0
         end
0
       end
0
 
0
@@ -36,31 +45,14 @@ module ActionController
0
       end
0
 
0
       def prepare_controller_class(new_class)
0
-        new_class.class_eval do
0
-          def rescue_action(e)
0
-            raise e
0
-          end
0
-        end
0
+        new_class.send :include, RaiseActionExceptions
0
       end
0
     end
0
 
0
-    def setup_with_controller
0
+    def setup_controller_request_and_response
0
       @controller = self.class.controller_class.new
0
       @request    = TestRequest.new
0
       @response   = TestResponse.new
0
     end
0
-    alias_method :setup, :setup_with_controller
0
-
0
-    def self.method_added(method)
0
-      if method.to_s == 'setup'
0
-        unless method_defined?(:setup_without_controller)
0
-          alias_method :setup_without_controller, :setup
0
-          define_method(:setup) do
0
-            setup_with_controller
0
-            setup_without_controller
0
-          end
0
-        end
0
-      end
0
-    end
0
  end
0
 end
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 require 'action_controller/assertions'
0
+require 'action_controller/test_case'
0
 
0
 module ActionController #:nodoc:
0
   class Base
...
84
85
86
87
 
88
89
90
...
84
85
86
 
87
88
89
90
0
@@ -84,7 +84,7 @@ class ActiveRecordTestConnector
0
   end
0
 end
0
 
0
-class ActiveRecordTestCase < Test::Unit::TestCase
0
+class ActiveRecordTestCase < ActiveSupport::TestCase
0
   # Set our fixture path
0
   if ActiveRecordTestConnector.able_to_connect
0
     self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
...
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
 
628
629
630
...
613
614
615
 
 
 
 
 
 
 
 
 
 
616
617
618
619
620
621
0
@@ -613,18 +613,9 @@ class InferringClassNameTest < Test::Unit::TestCase
0
     end
0
 end
0
 
0
-class ContentControllerTest < ActionController::TestCase
0
-  def setup
0
-    # Should not override ActionController setup methods
0
-  end
0
-
0
-  def test_should_still_setup_controller
0
-    assert_kind_of(ContentController, @controller)
0
-  end
0
-end
0
-
0
 class CrazyNameTest < ActionController::TestCase
0
   tests ContentController
0
+
0
   def test_controller_class_can_be_set_manually_not_just_inferred
0
     assert_equal ContentController, self.class.controller_class
0
   end
...
1
2
3
 
4
5
6
7
8
 
 
 
 
 
 
9
10
11
...
29
30
31
32
 
33
34
35
...
89
90
91
92
 
93
94
95
...
115
116
117
118
 
119
120
121
...
125
126
127
128
 
129
130
131
...
191
192
193
194
 
195
196
197
...
842
843
844
 
 
 
845
846
847
...
857
858
859
860
861
862
863
864
865
866
867
868
869
 
 
 
870
871
872
873
874
875
 
 
 
 
 
 
 
876
877
878
879
880
881
882
883
884
 
 
 
 
 
 
 
 
 
 
 
 
 
 
885
886
887
888
889
890
891
892
 
 
 
 
893
894
895
 
 
896
897
 
898
899
900
 
 
901
902
903
904
905
 
 
 
 
 
906
907
908
909
 
 
910
911
912
913
914
915
916
917
 
 
 
 
918
919
920
921
 
 
 
 
922
923
924
...
926
927
928
929
930
 
 
931
932
933
...
955
956
957
958
959
960
961
 
 
962
963
964
...
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
...
1
2
3
4
5
 
 
 
 
6
7
8
9
10
11
12
13
14
...
32
33
34
 
35
36
37
38
...
92
93
94
 
95
96
97
98
...
118
119
120
 
121
122
123
124
...
128
129
130
 
131
132
133
134
...
194
195
196
 
197
198
199
200
...
845
846
847
848
849
850
851
852
853
...
863
864
865
 
 
 
 
 
 
 
 
 
 
866
867
868
869
870
 
 
 
 
871
872
873
874
875
876
877
878
 
 
 
 
 
 
 
 
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
 
895
 
 
 
 
896
897
898
899
900
 
 
901
902
903
 
904
905
 
 
906
907
908
 
 
 
 
909
910
911
912
913
914
 
915
 
916
917
918
919
 
920
 
 
 
 
921
922
923
924
925
 
 
 
926
927
928
929
930
931
932
...
934
935
936
 
 
937
938
939
940
941
...
963
964
965
 
966
 
 
967
968
969
970
971
...
978
979
980
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
981
982
983
0
@@ -1,11 +1,14 @@
0
 require 'erb'
0
 require 'yaml'
0
 require 'csv'
0
+require 'active_support/test_case'
0
 
0
-module YAML #:nodoc:
0
-  class Omap #:nodoc:
0
-    def keys;   map { |k, v| k } end
0
-    def values; map { |k, v| v } end
0
+if RUBY_VERSION < '1.9'
0
+  module YAML #:nodoc:
0
+    class Omap #:nodoc:
0
+      def keys;   map { |k, v| k } end
0
+      def values; map { |k, v| v } end
0
+    end
0
   end
0
 end
0
 
0
@@ -29,7 +32,7 @@ end
0
 # in a non-verbose, human-readable format. It ships with Ruby 1.8.1+.
0
 #
0
 # Unlike single-file fixtures, YAML fixtures are stored in a single file per model, which are placed in the directory appointed
0
-# by <tt>Test::Unit::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just
0
+# by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just
0
 # put your files in <your-rails-app>/test/fixtures/). The fixture file ends with the .yml file extension (Rails example:
0
 # "<your-rails-app>/test/fixtures/web_sites.yml"). The format of a YAML fixture file looks like this:
0
 #
0
@@ -89,7 +92,7 @@ end
0
 #
0
 # This type of fixture was the original format for Active Record that has since been deprecated in favor of the YAML and CSV formats.
0
 # Fixtures for this format are created by placing text files in a sub-directory (with the name of the model) to the directory
0
-# appointed by <tt>Test::Unit::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just
0
+# appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically configured for Rails, so you can just
0
 # put your files in <your-rails-app>/test/fixtures/<your-model-name>/ -- like <your-rails-app>/test/fixtures/web_sites/ for the WebSite
0
 # model).
0
 #
0
@@ -115,7 +118,7 @@ end
0
 #
0
 #   require 'web_site'
0
 #
0
-#   class WebSiteTest < Test::Unit::TestCase
0
+#   class WebSiteTest < ActiveSupport::TestCase
0
 #     def test_web_site_count
0
 #       assert_equal 2, WebSite.count
0
 #     end
0
@@ -125,7 +128,7 @@ end
0
 # easiest way to add fixtures to the database:
0
 #
0
 #   ...
0
-#   class WebSiteTest < Test::Unit::TestCase
0
+#   class WebSiteTest < ActiveSupport::TestCase
0
 #     fixtures :web_sites # add more by separating the symbols with commas
0
 #   ...
0
 #
0
@@ -191,7 +194,7 @@ end
0
 # TestCases can use begin+rollback to isolate their changes to the database instead of having to delete+insert for every test case.
0
 # They can also turn off auto-instantiation of fixture data since the feature is costly and often unused.
0
 #
0
-#   class FooTest < Test::Unit::TestCase
0
+#   class FooTest < ActiveSupport::TestCase
0
 #     self.use_transactional_fixtures = true
0
 #     self.use_instantiated_fixtures = false
0
 #   
0
@@ -842,6 +845,9 @@ end
0
 module Test #:nodoc:
0
   module Unit #:nodoc:
0
     class TestCase #:nodoc:
0
+      setup :setup_fixtures
0
+      teardown :teardown_fixtures
0
+
0
       superclass_delegating_accessor :fixture_path
0
       superclass_delegating_accessor :fixture_table_names
0
       superclass_delegating_accessor :fixture_class_names
0
@@ -857,68 +863,70 @@ module Test #:nodoc:
0
       @@already_loaded_fixtures = {}
0
       self.fixture_class_names = {}
0
 
0
-      def self.set_fixture_class(class_names = {})
0
-        self.fixture_class_names = self.fixture_class_names.merge(class_names)
0
-      end
0
-
0
-      def self.fixtures(*table_names)
0
-        if table_names.first == :all
0
-          table_names = Dir["#{fixture_path}/*.yml"] + Dir["#{fixture_path}/*.csv"]
0
-          table_names.map! { |f| File.basename(f).split('.')[0..-2].join('.') }
0
-        else
0
-          table_names = table_names.flatten.map { |n| n.to_s }
0
+      class << self
0
+        def set_fixture_class(class_names = {})
0
+          self.fixture_class_names = self.fixture_class_names.merge(class_names)
0
         end
0
 
0
-        self.fixture_table_names |= table_names
0
-        require_fixture_classes(table_names)
0
-        setup_fixture_accessors(table_names)
0
-      end
0
+        def fixtures(*table_names)
0
+          if table_names.first == :all
0
+            table_names = Dir["#{fixture_path}/*.yml"] + Dir["#{fixture_path}/*.csv"]
0
+            table_names.map! { |f| File.basename(f).split('.')[0..-2].join('.') }
0
+          else
0
+            table_names = table_names.flatten.map { |n| n.to_s }
0
+          end
0
 
0
-      def self.require_fixture_classes(table_names = nil)
0
-        (table_names || fixture_table_names).each do |table_name|
0
-          file_name = table_name.to_s
0
-          file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names
0
-          begin
0
-            require_dependency file_name
0
-          rescue LoadError
0
-            # Let's hope the developer has included it himself
0
+          self.fixture_table_names |= table_names
0
+          require_fixture_classes(table_names)
0
+          setup_fixture_accessors(table_names)
0
+        end
0
+
0
+        def require_fixture_classes(table_names = nil)
0
+          (table_names || fixture_table_names).each do |table_name|
0
+            file_name = table_name.to_s
0
+            file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names
0
+            begin
0
+              require_dependency file_name
0
+            rescue LoadError
0
+              # Let's hope the developer has included it himself
0
+            end
0
           end
0
         end
0
-      end
0
 
0
-      def self.setup_fixture_accessors(table_names = nil)
0
-        table_names = [table_names] if table_names && !table_names.respond_to?(:each)
0
-        (table_names || fixture_table_names).each do |table_name|
0
-          table_name = table_name.to_s.tr('.', '_')
0
+        def setup_fixture_accessors(table_names = nil)
0
+          table_names = [table_names] if table_names && !table_names.respond_to?(:each)
0
+          (table_names || fixture_table_names).each do |table_name|
0
+            table_name = table_name.to_s.tr('.', '_')
0
 
0
-          define_method(table_name) do |*fixtures|
0
-            force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload
0
+            define_method(table_name) do |*fixtures|
0
+              force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload
0
 
0
-            @fixture_cache[table_name] ||= {}
0
+              @fixture_cache[table_name] ||= {}
0
 
0
-            instances = fixtures.map do |fixture|
0
-              @fixture_cache[table_name].delete(fixture) if force_reload
0
+              instances = fixtures.map do |fixture|
0
+                @fixture_cache[table_name].delete(fixture) if force_reload
0
 
0
-              if @loaded_fixtures[table_name][fixture.to_s]
0
-                @fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find
0
-              else
0
-                raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'"
0
+                if @loaded_fixtures[table_name][fixture.to_s]
0
+                  @fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find
0
+                else
0
+                  raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'"
0
+                end
0
               end
0
-            end
0
 
0
-            instances.size == 1 ? instances.first : instances
0
+              instances.size == 1 ? instances.first : instances
0
+            end
0
           end
0
         end
0
-      end
0
 
0
-      def self.uses_transaction(*methods)
0
-        @uses_transaction = [] unless defined?(@uses_transaction)
0
-        @uses_transaction.concat methods.map(&:to_s)
0
-      end
0
+        def uses_transaction(*methods)
0
+          @uses_transaction = [] unless defined?(@uses_transaction)
0
+          @uses_transaction.concat methods.map(&:to_s)
0
+        end
0
 
0
-      def self.uses_transaction?(method)
0
-        @uses_transaction = [] unless defined?(@uses_transaction)
0
-        @uses_transaction.include?(method.to_s)
0
+        def uses_transaction?(method)
0
+          @uses_transaction = [] unless defined?(@uses_transaction)
0
+          @uses_transaction.include?(method.to_s)
0
+        end
0
       end
0
 
0
       def use_transactional_fixtures?
0
@@ -926,8 +934,8 @@ module Test #:nodoc:
0
           !self.class.uses_transaction?(method_name)
0
       end
0
 
0
-      def setup_with_fixtures
0
-        return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
0
+      def setup_fixtures
0
+        return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
0
 
0
         if pre_loaded_fixtures && !use_transactional_fixtures
0
           raise RuntimeError, 'pre_loaded_fixtures requires use_transactional_fixtures'
0
@@ -955,10 +963,9 @@ module Test #:nodoc:
0
         # Instantiate fixtures for every test if requested.
0
         instantiate_fixtures if use_instantiated_fixtures
0
       end
0
-      alias_method :setup, :setup_with_fixtures
0
 
0
-      def teardown_with_fixtures
0
-        return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
0
+      def teardown_fixtures
0
+        return unless defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
0
 
0
         unless use_transactional_fixtures?
0
           Fixtures.reset_cache
0
@@ -971,28 +978,6 @@ module Test #:nodoc:
0
         end
0
         ActiveRecord::Base.verify_active_connections!
0
       end
0
-      alias_method :teardown, :teardown_with_fixtures
0
-
0
-      def self.method_added(method)
0
-        case method.to_s
0
-        when 'setup'
0
-          unless method_defined?(:setup_without_fixtures)
0
-            alias_method :setup_without_fixtures, :setup
0
-            define_method(:setup) do
0
-              setup_with_fixtures
0
-              setup_without_fixtures
0
-            end
0
-          end
0
-        when 'teardown'
0
-          unless method_defined?(:teardown_without_fixtures)
0
-            alias_method :teardown_without_fixtures, :teardown
0
-            define_method(:teardown) do
0
-              teardown_without_fixtures
0
-              teardown_with_fixtures
0
-            end
0
-          end
0
-        end
0
-      end
0
 
0
       private
0
         def load_fixtures
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 # The filename begins with "aaa" to ensure this is the first test.
0
 require 'abstract_unit'
0
 
0
-class AAACreateTablesTest < Test::Unit::TestCase
0
+class AAACreateTablesTest < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
 
0
   def setup
...
13
14
15
16
 
17
18
19
...
13
14
15
 
16
17
18
19
0
@@ -13,7 +13,7 @@ ActiveSupport::Deprecation.debug = true
0
 
0
 QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') unless Object.const_defined?(:QUOTED_TYPE)
0
 
0
-class Test::Unit::TestCase #:nodoc:
0
+class ActiveSupport::TestCase #:nodoc:
0
   self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
0
   self.use_instantiated_fixtures = false
0
   self.use_transactional_fixtures = (ENV['AR_NO_TX_FIXTURES'] != "yes")
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 require 'abstract_unit'
0
 
0
-class ActiveSchemaTest < Test::Unit::TestCase
0
+class ActiveSchemaTest < ActiveSupport::TestCase
0
   def setup
0
     ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
0
       alias_method :execute_without_stub, :execute
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 require 'abstract_unit'
0
 
0
-class AdapterTest < Test::Unit::TestCase
0
+class AdapterTest < ActiveSupport::TestCase
0
   def setup
0
     @connection = ActiveRecord::Base.connection
0
   end
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ require 'fixtures/default'
0
 require 'fixtures/post'
0
 require 'fixtures/task'
0
 
0
-class SqlServerAdapterTest < Test::Unit::TestCase
0
+class SqlServerAdapterTest < ActiveSupport::TestCase
0
   class TableWithRealColumn < ActiveRecord::Base; end
0
 
0
   fixtures :posts, :tasks
...
1
2
3
4
 
5
6
7
...
109
110
111
112
 
113
114
115
...
1
2
3
 
4
5
6
7
...
109
110
111
 
112
113
114
115
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/customer'
0
 
0
-class AggregationsTest < Test::Unit::TestCase
0
+class AggregationsTest < ActiveSupport::TestCase
0
   fixtures :customers
0
 
0
   def test_find_single_value_object
0
@@ -109,7 +109,7 @@ class AggregationsTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class OverridingAggregationsTest < Test::Unit::TestCase
0
+class OverridingAggregationsTest < ActiveSupport::TestCase
0
   class Name; end
0
   class DifferentName; end
0
 
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ require "#{File.dirname(__FILE__)}/../lib/active_record/schema"
0
 
0
 if ActiveRecord::Base.connection.supports_migrations? 
0
 
0
-  class ActiveRecordSchemaTest < Test::Unit::TestCase
0
+  class ActiveRecordSchemaTest < ActiveSupport::TestCase
0
     self.use_transactional_fixtures = false
0
 
0
     def setup
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/company'
0
 
0
-class AssociationInheritanceReloadTest < Test::Unit::TestCase
0
+class AssociationInheritanceReloadTest < ActiveSupport::TestCase
0
   fixtures :companies
0
 
0
   def test_set_attributes
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ require 'fixtures/category'
0
 require 'fixtures/project'
0
 require 'fixtures/developer'
0
 
0
-class AssociationCallbacksTest < Test::Unit::TestCase
0
+class AssociationCallbacksTest < ActiveSupport::TestCase
0
   fixtures :posts, :authors, :projects, :developers
0
 
0
   def setup
...
8
9
10
11
 
12
13
14
...
95
96
97
98
 
99
100
101
...
8
9
10
 
11
12
13
14
...
95
96
97
 
98
99
100
101
0
@@ -8,7 +8,7 @@ require 'fixtures/company'
0
 require 'fixtures/topic'
0
 require 'fixtures/reply'
0
 
0
-class CascadedEagerLoadingTest < Test::Unit::TestCase
0
+class CascadedEagerLoadingTest < ActiveSupport::TestCase
0
   fixtures :authors, :mixins, :companies, :posts, :topics
0
 
0
   def test_eager_association_loading_with_cascaded_two_levels
0
@@ -95,7 +95,7 @@ end
0
 
0
 require 'fixtures/vertex'
0
 require 'fixtures/edge'
0
-class CascadedEagerLoadingTest < Test::Unit::TestCase
0
+class CascadedEagerLoadingTest < ActiveSupport::TestCase
0
   fixtures :edges, :vertices
0
 
0
   def test_eager_association_loading_with_recursive_cascading_four_levels_has_many_through
...
39
40
41
42
 
43
44
45
...
39
40
41
 
42
43
44
45
0
@@ -39,7 +39,7 @@ class Compress < ActiveRecord::Base
0
 end
0
 
0
 
0
-class EagerSingularizationTest < Test::Unit::TestCase
0
+class EagerSingularizationTest < ActiveSupport::TestCase
0
 
0
   def setup
0
     if ActiveRecord::Base.connection.supports_migrations?
...
7
8
9
10
 
11
12
13
...
7
8
9
 
10
11
12
13
0
@@ -7,7 +7,7 @@ require 'fixtures/company'
0
 require 'fixtures/person'
0
 require 'fixtures/reader'
0
 
0
-class EagerAssociationTest < Test::Unit::TestCase
0
+class EagerAssociationTest < ActiveSupport::TestCase
0
   fixtures :posts, :comments, :authors, :categories, :categories_posts,
0
             :companies, :accounts, :tags, :people, :readers
0
 
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,7 +4,7 @@ require 'fixtures/comment'
0
 require 'fixtures/project'
0
 require 'fixtures/developer'
0
 
0
-class AssociationsExtensionsTest < Test::Unit::TestCase
0
+class AssociationsExtensionsTest < ActiveSupport::TestCase
0
   fixtures :projects, :developers, :developers_projects, :comments, :posts
0
 
0
   def test_extension_on_has_many
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@ require 'fixtures/author'
0
 require 'fixtures/category'
0
 require 'fixtures/categorization'
0
 
0
-class InnerJoinAssociationTest < Test::Unit::TestCase
0
+class InnerJoinAssociationTest < ActiveSupport::TestCase
0
   fixtures :authors, :posts, :comments, :categories, :categories_posts, :categorizations
0
 
0
   def test_construct_finder_sql_creates_inner_joins
...
12
13
14
15
 
16
17
18
...
12
13
14
 
15
16
17
18
0
@@ -12,7 +12,7 @@ require 'fixtures/edge'
0
 require 'fixtures/book'
0
 require 'fixtures/citation'
0
 
0
-class AssociationsJoinModelTest < Test::Unit::TestCase
0
+class AssociationsJoinModelTest < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
   fixtures :posts, :authors, :categories, :categorizations, :comments, :tags, :taggings, :author_favorites, :vertices, :items, :books
0
 
...
17
18
19
20
 
21
22
23
...
73
74
75
76
 
77
78
79
...
166
167
168
169
 
170
171
172
...
463
464
465
466
 
467
468
469
...
1196
1197
1198
1199
 
1200
1201
1202
...
1572
1573
1574
1575
 
1576
1577
1578
...
2112
2113
2114
2115
 
2116
2117
2118
...
17
18
19
 
20
21
22
23
...
73
74
75
 
76
77
78
79
...
166
167
168
 
169
170
171
172
...
463
464
465
 
466
467
468
469
...
1196
1197
1198
 
1199
1200
1201
1202
...
1572
1573
1574
 
1575
1576
1577
1578
...
2112
2113
2114
 
2115
2116
2117
2118
0
@@ -17,7 +17,7 @@ require 'fixtures/tagging'
0
 require 'fixtures/person'
0
 require 'fixtures/reader'
0
 
0
-class AssociationsTest < Test::Unit::TestCase
0
+class AssociationsTest < ActiveSupport::TestCase
0
   fixtures :accounts, :companies, :developers, :projects, :developers_projects,
0
            :computers
0
 
0
@@ -73,7 +73,7 @@ class AssociationsTest < Test::Unit::TestCase
0
   end
0
 end
0
  
0
-class AssociationProxyTest < Test::Unit::TestCase
0
+class AssociationProxyTest < ActiveSupport::TestCase
0
   fixtures :authors, :posts, :categorizations, :categories, :developers, :projects, :developers_projects
0
   
0
   def test_proxy_accessors
0
@@ -166,7 +166,7 @@ class AssociationProxyTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class HasOneAssociationsTest < Test::Unit::TestCase
0
+class HasOneAssociationsTest < ActiveSupport::TestCase
0
   fixtures :accounts, :companies, :developers, :projects, :developers_projects
0
 
0
   def setup
0
@@ -463,7 +463,7 @@ class HasOneAssociationsTest < Test::Unit::TestCase
0
 end
0
 
0
 
0
-class HasManyAssociationsTest < Test::Unit::TestCase
0
+class HasManyAssociationsTest < ActiveSupport::TestCase
0
   fixtures :accounts, :companies, :developers, :projects,
0
            :developers_projects, :topics, :authors, :comments
0
 
0
@@ -1196,7 +1196,7 @@ class HasManyAssociationsTest < Test::Unit::TestCase
0
 
0
 end
0
 
0
-class BelongsToAssociationsTest < Test::Unit::TestCase
0
+class BelongsToAssociationsTest < ActiveSupport::TestCase
0
   fixtures :accounts, :companies, :developers, :projects, :topics,
0
            :developers_projects, :computers, :authors, :posts, :tags, :taggings
0
 
0
@@ -1572,7 +1572,7 @@ class DeveloperForProjectWithAfterCreateHook < ActiveRecord::Base
0
 end
0
 
0
 
0
-class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
0
+class HasAndBelongsToManyAssociationsTest < ActiveSupport::TestCase
0
   fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects
0
 
0
   def test_has_and_belongs_to_many
0
@@ -2112,7 +2112,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
0
 end
0
 
0
 
0
-class OverridingAssociationsTest < Test::Unit::TestCase
0
+class OverridingAssociationsTest < ActiveSupport::TestCase
0
   class Person < ActiveRecord::Base; end
0
   class DifferentPerson < ActiveRecord::Base; end
0
 
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/topic'
0
 
0
-class AttributeMethodsTest < Test::Unit::TestCase
0
+class AttributeMethodsTest < ActiveSupport::TestCase
0
   fixtures :topics
0
   def setup
0
     @old_suffixes = ActiveRecord::Base.send(:attribute_method_suffixes).dup
...
70
71
72
73
 
74
75
76
...
70
71
72
 
73
74
75
76
0
@@ -70,7 +70,7 @@ class TopicWithProtectedContentAndAccessibleAuthorName < ActiveRecord::Base
0
   attr_protected  :content
0
 end
0
 
0
-class BasicsTest < Test::Unit::TestCase
0
+class BasicsTest < ActiveSupport::TestCase
0
   fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics
0
 
0
   def test_table_exists
...
10
11
12
13
 
14
15
16
...
10
11
12
 
13
14
15
16
0
@@ -10,7 +10,7 @@ require 'abstract_unit'
0
 unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
0
   require 'fixtures/binary'
0
 
0
-  class BinaryTest < Test::Unit::TestCase
0
+  class BinaryTest < ActiveSupport::TestCase
0
     FIXTURES = %w(flowers.jpg example.log)
0
 
0
     def test_load_save
...
8
9
10
11
 
12
13
14
...
8
9
10
 
11
12
13
14
0
@@ -8,7 +8,7 @@ class NumericData < ActiveRecord::Base
0
   self.table_name = 'numeric_data'
0
 end
0
 
0
-class CalculationsTest < Test::Unit::TestCase
0
+class CalculationsTest < ActiveSupport::TestCase
0
   fixtures :companies, :accounts, :topics
0
 
0
   def test_should_sum_field
...
126
127
128
129
 
130
131
132
...
126
127
128
 
129
130
131
132
0
@@ -126,7 +126,7 @@ class CallbackCancellationDeveloper < ActiveRecord::Base
0
   end
0
 end
0
 
0
-class CallbacksTest < Test::Unit::TestCase
0
+class CallbacksTest < ActiveSupport::TestCase
0
   fixtures :developers
0
 
0
   def test_initialize
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@ class D < B
0
 end
0
 
0
 
0
-class ClassInheritableAttributesTest < Test::Unit::TestCase
0
+class ClassInheritableAttributesTest < ActiveSupport::TestCase
0
   def test_first_level
0
     assert_equal [ :one, :two ], B.read_inheritable_attribute("first")
0
     assert_equal [ :three ], C.read_inheritable_attribute("first")
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/topic'
0
 
0
-class TestColumnAlias < Test::Unit::TestCase
0
+class TestColumnAlias < ActiveSupport::TestCase
0
   fixtures :topics
0
 
0
   QUERY = if 'Oracle' == ActiveRecord::Base.connection.adapter_name
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 require "#{File.dirname(__FILE__)}/abstract_unit"
0
 
0
-class FirebirdConnectionTest < Test::Unit::TestCase
0
+class FirebirdConnectionTest < ActiveSupport::TestCase
0
   def test_charset_properly_set
0
     fb_conn = ActiveRecord::Base.connection.instance_variable_get(:@connection)
0
     assert_equal 'UTF8', fb_conn.database.character_set
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 require "#{File.dirname(__FILE__)}/abstract_unit"
0
 
0
-class MysqlConnectionTest < Test::Unit::TestCase
0
+class MysqlConnectionTest < ActiveSupport::TestCase
0
   def setup
0
     @connection = ActiveRecord::Base.connection
0
   end
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 require 'abstract_unit'
0
 
0
-class CopyTableTest < Test::Unit::TestCase
0
+class CopyTableTest < ActiveSupport::TestCase
0
   fixtures :companies, :comments
0
   
0
   def setup
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ end
0
 class PostgresqlOid < ActiveRecord::Base
0
 end
0
 
0
-class PostgresqlDataTypeTest < Test::Unit::TestCase
0
+class PostgresqlDataTypeTest < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
 
0
   def setup
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@ require 'abstract_unit'
0
 require 'fixtures/topic'
0
 require 'fixtures/task'
0
 
0
-class DateTimeTest < Test::Unit::TestCase
0
+class DateTimeTest < ActiveSupport::TestCase
0
   def test_saves_both_date_and_time
0
     time_values = [1807, 2, 10, 15, 30, 45]
0
     now = DateTime.civil(*time_values)
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/default'
0
 
0
-class DefaultTest < Test::Unit::TestCase
0
+class DefaultTest < ActiveSupport::TestCase
0
   def test_default_timestamp
0
     default = Default.new
0
     assert_instance_of(Time, default.default_timestamp)
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@ require 'abstract_unit'
0
 require 'fixtures/default'
0
 require 'fixtures/entrant'
0
 
0
-class DefaultTest < Test::Unit::TestCase
0
+class DefaultTest < ActiveSupport::TestCase
0
   def test_nil_defaults_for_not_null_columns
0
     column_defaults =
0
       if current_adapter?(:MysqlAdapter)
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/entrant'
0
 
0
-class DeprecatedFinderTest < Test::Unit::TestCase
0
+class DeprecatedFinderTest < ActiveSupport::TestCase
0
   fixtures :entrants
0
 
0
   def test_deprecated_find_all_was_removed
...
8
9
10
11
 
12
13
14
...
8
9
10
 
11
12
13
14
0
@@ -8,7 +8,7 @@ require 'fixtures/entrant'
0
 require 'fixtures/developer'
0
 require 'fixtures/post'
0
 
0
-class FinderTest < Test::Unit::TestCase
0
+class FinderTest < ActiveSupport::TestCase
0
   fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :comments, :accounts, :authors
0
 
0
   def test_find
...
16
17
18
19
 
20
21
22
...
204
205
206
207
 
208
209
210
...
250
251
252
253
 
254
255
256
...
285
286
287
288
 
289
290
291
...
299
300
301
302
 
303
304
305
...
315
316
317
318
 
319
320
321
...
324
325
326
327
 
328
329
330
...
348
349
350
351
 
352
353
354
...
357
358
359
360
 
361
362
363
...
373
374
375
376
 
377
378
379
...
382
383
384
385
 
386
387
388
...
392
393
394
395
 
396
397
398
...
402
403
404
405
 
406
407
408
...
412
413
414
415
 
416
417
418
...
420
421
422
423
 
424
425
426
 
 
427
428
429
430
431
 
 
432
433
434
435
436
 
437
438
 
439
440
441
...
445
446
447
448
 
449
450
451
...
454
455
456
457
 
458
459
460
...
479
480
481
482
 
483
484
485
...
16
17
18
 
19
20
21
22
...
204
205
206
 
207
208
209
210
...
250
251
252
 
253
254
255
256
...
285
286
287
 
288
289
290
291
...
299
300
301
 
302
303
304
305
...
315
316
317
 
318
319
320
321
...
324
325
326
 
327
328
329
330
...
348
349
350
 
351
352
353
354
...
357
358
359
 
360
361
362
363
...
373
374
375
 
376
377
378
379
...
382
383
384
 
385
386
387
388
...
392
393
394
 
395
396
397
398
...
402
403
404
 
405
406
407
408
...
412
413
414
 
415
416
417
418
...
420
421
422
 
423
424
 
 
425
426
427
428
429
 
 
430
431
432
433
434
435
 
436
437
 
438
439
440
441
...
445
446
447
 
448
449
450
451
...
454
455
456
 
457
458
459
460
...
479
480
481
 
482
483
484
485
0
@@ -16,7 +16,7 @@ require 'fixtures/treasure'
0
 require 'fixtures/matey'
0
 require 'fixtures/ship'
0
 
0
-class FixturesTest < Test::Unit::TestCase
0
+class FixturesTest < ActiveSupport::TestCase
0
   self.use_instantiated_fixtures = true
0
   self.use_transactional_fixtures = false
0
 
0
@@ -204,7 +204,7 @@ class FixturesTest < Test::Unit::TestCase
0
 end
0
 
0
 if Account.connection.respond_to?(:reset_pk_sequence!)
0
-  class FixturesResetPkSequenceTest < Test::Unit::TestCase
0
+  class FixturesResetPkSequenceTest < ActiveSupport::TestCase
0
     fixtures :accounts
0
     fixtures :companies
0
 
0
@@ -250,7 +250,7 @@ if Account.connection.respond_to?(:reset_pk_sequence!)
0
   end
0
 end
0
 
0
-class FixturesWithoutInstantiationTest < Test::Unit::TestCase
0
+class FixturesWithoutInstantiationTest < ActiveSupport::TestCase
0
   self.use_instantiated_fixtures = false
0
   fixtures :topics, :developers, :accounts
0
 
0
@@ -285,7 +285,7 @@ class FixturesWithoutInstantiationTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class FixturesWithoutInstanceInstantiationTest < Test::Unit::TestCase
0
+class FixturesWithoutInstanceInstantiationTest < ActiveSupport::TestCase
0
   self.use_instantiated_fixtures = true
0
   self.use_instantiated_fixtures = :no_instances
0
 
0
@@ -299,7 +299,7 @@ class FixturesWithoutInstanceInstantiationTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class TransactionalFixturesTest < Test::Unit::TestCase
0
+class TransactionalFixturesTest < ActiveSupport::TestCase
0
   self.use_instantiated_fixtures = true
0
   self.use_transactional_fixtures = true
0
 
0
@@ -315,7 +315,7 @@ class TransactionalFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class MultipleFixturesTest < Test::Unit::TestCase
0
+class MultipleFixturesTest < ActiveSupport::TestCase
0
   fixtures :topics
0
   fixtures :developers, :accounts
0
 
0
@@ -324,7 +324,7 @@ class MultipleFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class SetupTest < Test::Unit::TestCase
0
+class SetupTest < ActiveSupport::TestCase
0
   # fixtures :topics
0
   
0
   def setup
0
@@ -348,7 +348,7 @@ class SetupSubclassTest < SetupTest
0
 end
0
 
0
 
0
-class OverlappingFixturesTest < Test::Unit::TestCase
0
+class OverlappingFixturesTest < ActiveSupport::TestCase
0
   fixtures :topics, :developers
0
   fixtures :developers, :accounts
0
 
0
@@ -357,7 +357,7 @@ class OverlappingFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class ForeignKeyFixturesTest < Test::Unit::TestCase
0
+class ForeignKeyFixturesTest < ActiveSupport::TestCase
0
   fixtures :fk_test_has_pk, :fk_test_has_fk
0
 
0
   # if foreign keys are implemented and fixtures
0
@@ -373,7 +373,7 @@ class ForeignKeyFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class SetTableNameFixturesTest < Test::Unit::TestCase
0
+class SetTableNameFixturesTest < ActiveSupport::TestCase
0
   set_fixture_class :funny_jokes => 'Joke'
0
   fixtures :funny_jokes
0
 
0
@@ -382,7 +382,7 @@ class SetTableNameFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class CustomConnectionFixturesTest < Test::Unit::TestCase
0
+class CustomConnectionFixturesTest < ActiveSupport::TestCase
0
   set_fixture_class :courses => Course
0
   fixtures :courses
0
 
0
@@ -392,7 +392,7 @@ class CustomConnectionFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class InvalidTableNameFixturesTest < Test::Unit::TestCase
0
+class InvalidTableNameFixturesTest < ActiveSupport::TestCase
0
   fixtures :funny_jokes
0
 
0
   def test_raises_error
0
@@ -402,7 +402,7 @@ class InvalidTableNameFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class CheckEscapedYamlFixturesTest < Test::Unit::TestCase
0
+class CheckEscapedYamlFixturesTest < ActiveSupport::TestCase
0
   set_fixture_class :funny_jokes => 'Joke'
0
   fixtures :funny_jokes
0
 
0
@@ -412,7 +412,7 @@ class CheckEscapedYamlFixturesTest < Test::Unit::TestCase
0
 end
0
 
0
 class DevelopersProject; end
0
-class ManyToManyFixturesWithClassDefined < Test::Unit::TestCase
0
+class ManyToManyFixturesWithClassDefined < ActiveSupport::TestCase
0
   fixtures :developers_projects
0
 
0
   def test_this_should_run_cleanly
0
@@ -420,22 +420,22 @@ class ManyToManyFixturesWithClassDefined < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class FixturesBrokenRollbackTest < Test::Unit::TestCase
0
+class FixturesBrokenRollbackTest < ActiveSupport::TestCase
0
   def blank_setup; end
0
-  alias_method :ar_setup_with_fixtures, :setup_with_fixtures
0
-  alias_method :setup_with_fixtures, :blank_setup
0
+  alias_method :ar_setup_fixtures, :setup_fixtures
0
+  alias_method :setup_fixtures, :blank_setup
0
   alias_method :setup, :blank_setup
0
 
0
   def blank_teardown; end
0
-  alias_method :ar_teardown_with_fixtures, :teardown_with_fixtures
0
-  alias_method :teardown_with_fixtures, :blank_teardown
0
+  alias_method :ar_teardown_fixtures, :teardown_fixtures
0
+  alias_method :teardown_fixtures, :blank_teardown
0
   alias_method :teardown, :blank_teardown
0
 
0
   def test_no_rollback_in_teardown_unless_transaction_active
0
     assert_equal 0, Thread.current['open_transactions']
0
-    assert_raise(RuntimeError) { ar_setup_with_fixtures }
0
+    assert_raise(RuntimeError) { ar_setup_fixtures }
0
     assert_equal 0, Thread.current['open_transactions']
0
-    assert_nothing_raised { ar_teardown_with_fixtures }
0
+    assert_nothing_raised { ar_teardown_fixtures }
0
     assert_equal 0, Thread.current['open_transactions']
0
   end
0
 
0
@@ -445,7 +445,7 @@ class FixturesBrokenRollbackTest < Test::Unit::TestCase
0
     end
0
 end
0
 
0
-class LoadAllFixturesTest < Test::Unit::TestCase
0
+class LoadAllFixturesTest < ActiveSupport::TestCase
0
   self.fixture_path= File.join(File.dirname(__FILE__), '/fixtures/all')
0
   fixtures :all
0
 
0
@@ -454,7 +454,7 @@ class LoadAllFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class FasterFixturesTest < Test::Unit::TestCase
0
+class FasterFixturesTest < ActiveSupport::TestCase
0
   fixtures :categories, :authors
0
 
0
   def load_extra_fixture(name)
0
@@ -479,7 +479,7 @@ class FasterFixturesTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class FoxyFixturesTest < Test::Unit::TestCase
0
+class FoxyFixturesTest < ActiveSupport::TestCase
0
   fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers, :developers
0
 
0
   def test_identifies_strings
...
3
4
5
6
 
7
8
9
...
175
176
177
178
 
179
180
181
...
3
4
5
 
6
7
8
9
...
175
176
177
 
178
179
180
181
0
@@ -3,7 +3,7 @@ require 'fixtures/company'
0
 require 'fixtures/project'
0
 require 'fixtures/subscriber'
0
 
0
-class InheritanceTest < Test::Unit::TestCase
0
+class InheritanceTest < ActiveSupport::TestCase
0
   fixtures :companies, :projects, :subscribers, :accounts
0
 
0
   def test_company_descends_from_active_record
0
@@ -175,7 +175,7 @@ class InheritanceTest < Test::Unit::TestCase
0
 end
0
 
0
 
0
-class InheritanceComputeTypeTest < Test::Unit::TestCase
0
+class InheritanceComputeTypeTest < ActiveSupport::TestCase
0
   fixtures :companies
0
 
0
   def setup
...
6
7
8
9
 
10
11
12
...
63
64
65
66
 
67
68
69
...
6
7
8
 
9
10
11
12
...
63
64
65
 
66
67
68
69
0
@@ -6,7 +6,7 @@ require 'fixtures/tagging'
0
 require 'fixtures/tag'
0
 require 'fixtures/comment'
0
 
0
-class JsonSerializationTest < Test::Unit::TestCase
0
+class JsonSerializationTest < ActiveSupport::TestCase
0
   def setup
0
     @contact = Contact.new(
0
       :name        => 'Konata Izumi',
0
@@ -63,7 +63,7 @@ class JsonSerializationTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class DatabaseConnectedJsonEncodingTest < Test::Unit::TestCase
0
+class DatabaseConnectedJsonEncodingTest < ActiveSupport::TestCase
0
   fixtures :authors, :posts, :comments, :tags, :taggings
0
 
0
   def setup
...
64
65
66
67
 
68
69
70
...
64
65
66
 
67
68
69
70
0
@@ -64,7 +64,7 @@ class MultiObserver < ActiveRecord::Observer
0
   end
0
 end
0
 
0
-class LifecycleTest < Test::Unit::TestCase
0
+class LifecycleTest < ActiveSupport::TestCase
0
   fixtures :topics, :developers
0
 
0
   def test_before_destroy
...
14
15
16
17
 
18
19
20
...
176
177
178
179
 
180
181
182
...
14
15
16
 
17
18
19
20
...
176
177
178
 
179
180
181
182
0
@@ -14,7 +14,7 @@ class ReadonlyFirstNamePerson < Person
0
   attr_readonly :first_name
0
 end
0
 
0
-class OptimisticLockingTest < Test::Unit::TestCase
0
+class OptimisticLockingTest < ActiveSupport::TestCase
0
   fixtures :people, :legacy_things
0
 
0
   # need to disable transactional fixtures, because otherwise the sqlite3
0
@@ -176,7 +176,7 @@ end
0
 # TODO: The SQL Server, Sybase, and OpenBase adapters currently have no support for pessimistic locking
0
 
0
 unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :OpenBaseAdapter)
0
-  class PessimisticLockingTest < Test::Unit::TestCase
0
+  class PessimisticLockingTest < ActiveSupport::TestCase
0
     self.use_transactional_fixtures = false
0
     fixtures :people, :readers
0
 
...
5
6
7
8
 
9
10
11
...
125
126
127
128
 
129
130
131
...
313
314
315
316
 
317
318
319
...
343
344
345
346
 
347
348
349
...
373
374
375
376
 
377
378
379
...
393
394
395
396
 
397
398
399
...
5
6
7
 
8
9
10
11
...
125
126
127
 
128
129
130
131
...
313
314
315
 
316
317
318
319
...
343
344
345
 
346
347
348
349
...
373
374
375
 
376
377
378
379
...
393
394
395
 
396
397
398
399
0
@@ -5,7 +5,7 @@ require 'fixtures/comment'
0
 require 'fixtures/post'
0
 require 'fixtures/category'
0
 
0
-class MethodScopingTest < Test::Unit::TestCase
0
+class MethodScopingTest < ActiveSupport::TestCase
0
   fixtures :developers, :projects, :comments, :posts
0
   
0
   def test_set_conditions
0
@@ -125,7 +125,7 @@ class MethodScopingTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class NestedScopingTest < Test::Unit::TestCase
0
+class NestedScopingTest < ActiveSupport::TestCase
0
   fixtures :developers, :projects, :comments, :posts
0
 
0
   def test_merge_options
0
@@ -313,7 +313,7 @@ class NestedScopingTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class HasManyScopingTest< Test::Unit::TestCase
0
+class HasManyScopingTest< ActiveSupport::TestCase
0
   fixtures :comments, :posts
0
   
0
   def setup
0
@@ -343,7 +343,7 @@ class HasManyScopingTest< Test::Unit::TestCase
0
 end
0
 
0
 
0
-class HasAndBelongsToManyScopingTest< Test::Unit::TestCase
0
+class HasAndBelongsToManyScopingTest< ActiveSupport::TestCase
0
   fixtures :posts, :categories, :categories_posts
0
 
0
   def setup
0
@@ -373,7 +373,7 @@ end
0
 # We disabled the scoping for has_one and belongs_to as we can't think of a proper use case
0
 
0
 
0
-class BelongsToScopingTest< Test::Unit::TestCase
0
+class BelongsToScopingTest< ActiveSupport::TestCase
0
   fixtures :comments, :posts
0
 
0
   def setup
0
@@ -393,7 +393,7 @@ class BelongsToScopingTest< Test::Unit::TestCase
0
 end
0
 
0
 
0
-class HasOneScopingTest< Test::Unit::TestCase
0
+class HasOneScopingTest< ActiveSupport::TestCase
0
   fixtures :comments, :posts
0
 
0
   def setup
...
22
23
24
25
 
26
27
28
...
909
910
911
912
 
913
914
915
...
22
23
24
 
25
26
27
28
...
909
910
911
 
912
913
914
915
0
@@ -22,7 +22,7 @@ if ActiveRecord::Base.connection.supports_migrations?
0
     end
0
   end
0
 
0
-  class MigrationTest < Test::Unit::TestCase
0
+  class MigrationTest < ActiveSupport::TestCase
0
     self.use_transactional_fixtures = false
0
     
0
     fixtures :people
0
@@ -909,7 +909,7 @@ if ActiveRecord::Base.connection.supports_migrations?
0
   end
0
 
0
   uses_mocha 'Sexy migration tests' do
0
-    class SexyMigrationsTest < Test::Unit::TestCase
0
+    class SexyMigrationsTest < ActiveSupport::TestCase
0
       def test_references_column_type_adds_id
0
         with_new_table do |t|
0
           t.expects(:column).with('customer_id', :integer, {})
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/course'
0
 
0
-class FirebirdMigrationTest < Test::Unit::TestCase
0
+class FirebirdMigrationTest < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
 
0
   def setup
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ class Time
0
 end
0
 
0
 
0
-class TouchTest < Test::Unit::TestCase
0
+class TouchTest < ActiveSupport::TestCase
0
   fixtures :mixins
0
   
0
   def setup
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/company_in_module'
0
 
0
-class ModulesTest < Test::Unit::TestCase
0
+class ModulesTest < ActiveSupport::TestCase
0
   fixtures :accounts, :companies, :projects, :developers
0
 
0
   def test_module_spanning_associations
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,7 +4,7 @@ require 'fixtures/entrant'
0
 # So we can test whether Course.connection survives a reload.
0
 require_dependency 'fixtures/course'
0
 
0
-class MultipleDbTest < Test::Unit::TestCase
0
+class MultipleDbTest < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
 
0
   def setup
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ require 'fixtures/movie'
0
 require 'fixtures/keyboard'
0
 require 'fixtures/mixed_case_monkey'
0
 
0
-class PrimaryKeysTest < Test::Unit::TestCase
0
+class PrimaryKeysTest < ActiveSupport::TestCase
0
   fixtures :topics, :subscribers, :movies, :mixed_case_monkeys
0
 
0
   def test_integer_key
...
5
6
7
8
 
9
10
11
...
55
56
57
58
 
59
60
61
...
5
6
7
 
8
9
10
11
...
55
56
57
 
58
59
60
61
0
@@ -5,7 +5,7 @@ require 'fixtures/task'
0
 require 'fixtures/course'
0
 
0
 
0
-class QueryCacheTest < Test::Unit::TestCase
0
+class QueryCacheTest < ActiveSupport::TestCase
0
   fixtures :tasks, :topics
0
 
0
   def test_find_queries
0
@@ -55,7 +55,7 @@ end
0
 
0
 uses_mocha 'QueryCacheExpiryTest' do
0
 
0
-class QueryCacheExpiryTest < Test::Unit::TestCase
0
+class QueryCacheExpiryTest < ActiveSupport::TestCase
0
   fixtures :tasks
0
 
0
   def test_find
...
11
12
13
14
 
15
16
17
...
11
12
13
 
14
15
16
17
0
@@ -11,7 +11,7 @@ def Comment.foo() find :first end
0
 def Project.foo() find :first end
0
 
0
 
0
-class ReadOnlyTest < Test::Unit::TestCase
0
+class ReadOnlyTest < ActiveSupport::TestCase
0
   fixtures :posts, :comments, :developers, :projects, :developers_projects
0
 
0
   def test_cant_save_readonly_record
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@ require 'fixtures/company'
0
 require 'fixtures/company_in_module'
0
 require 'fixtures/subscriber'
0
 
0
-class ReflectionTest < Test::Unit::TestCase
0
+class ReflectionTest < ActiveSupport::TestCase
0
   fixtures :topics, :customers, :companies, :subscribers
0
 
0
   def setup
...
23
24
25
26
 
27
28
29
...
23
24
25
 
26
27
28
29
0
@@ -23,7 +23,7 @@ end
0
 
0
 # a suite of tests to ensure the ConnectionAdapters#MysqlAdapter can handle tables with
0
 # reserved word names (ie: group, order, values, etc...)
0
-class MysqlReservedWordTest < Test::Unit::TestCase
0
+class MysqlReservedWordTest < ActiveSupport::TestCase
0
   def setup
0
     @connection = ActiveRecord::Base.connection
0
 
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ require 'abstract_unit'
0
 class SchemaThing < ActiveRecord::Base
0
 end
0
 
0
-class SchemaAuthorizationTest < Test::Unit::TestCase
0
+class SchemaAuthorizationTest < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
 
0
   TABLE_NAME = 'schema_things'
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,7 +4,7 @@ require 'stringio'
0
 
0
 if ActiveRecord::Base.connection.respond_to?(:tables)
0
 
0
-  class SchemaDumperTest < Test::Unit::TestCase
0
+  class SchemaDumperTest < ActiveSupport::TestCase
0
     def standard_dump
0
       stream = StringIO.new
0
       ActiveRecord::SchemaDumper.ignore_tables = []
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 require 'abstract_unit'
0
 
0
-class SchemaTest < Test::Unit::TestCase
0
+class SchemaTest < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
 
0
   SCHEMA_NAME = 'test_schema'
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 require 'abstract_unit'
0
 require 'fixtures/contact'
0
 
0
-class SerializationTest < Test::Unit::TestCase
0
+class SerializationTest < ActiveSupport::TestCase
0
   FORMATS = [ :xml, :json ]
0
   
0
   def setup
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ require 'fixtures/subject'
0
 # the "subjects" table in Oracle (defined in oci.sql) is just
0
 # a synonym to the "topics" table
0
 
0
-class TestOracleSynonym < Test::Unit::TestCase
0
+class TestOracleSynonym < ActiveSupport::TestCase
0
 
0
   def test_oracle_synonym
0
     topic = Topic.new
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ if ActiveRecord::Base.connection.supports_migrations?
0
     self.table_name = '[order]'
0
   end
0
 
0
-  class TableNameTest < Test::Unit::TestCase
0
+  class TableNameTest < ActiveSupport::TestCase
0
     self.use_transactional_fixtures = false
0
 
0
     # Ensures Model.columns works when using SQLServer escape characters.
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ require 'fixtures/topic'
0
 require 'fixtures/reply'
0
 
0
 unless %w(FrontBase).include? ActiveRecord::Base.connection.adapter_name
0
-  class ThreadedConnectionsTest < Test::Unit::TestCase
0
+  class ThreadedConnectionsTest < ActiveSupport::TestCase
0
     self.use_transactional_fixtures = false
0
 
0
     fixtures :topics
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ require 'fixtures/topic'
0
 require 'fixtures/reply'
0
 require 'fixtures/developer'
0
 
0
-class TransactionTest < Test::Unit::TestCase
0
+class TransactionTest < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
   fixtures :topics, :developers
0
 
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ require 'abstract_unit'
0
 class TestRecord < ActiveRecord::Base
0
 end
0
 
0
-class TestUnconnectedAdapter < Test::Unit::TestCase
0
+class TestUnconnectedAdapter < ActiveSupport::TestCase
0
   self.use_transactional_fixtures = false
0
 
0
   def setup
...
53
54
55
56
 
57
58
59
...
1273
1274
1275
1276
 
1277
1278
1279
...
53
54
55
 
56
57
58
59
...
1273
1274
1275
 
1276
1277
1278
1279
0
@@ -53,7 +53,7 @@ end
0
 class Thaumaturgist < IneptWizard
0
 end
0
 
0
-class ValidationsTest < Test::Unit::TestCase
0
+class ValidationsTest < ActiveSupport::TestCase
0
   fixtures :topics, :developers
0
 
0
   def setup
0
@@ -1273,7 +1273,7 @@ class ValidationsTest < Test::Unit::TestCase
0
 end
0
 
0
 
0
-class ValidatesNumericalityTest < Test::Unit::TestCase
0
+class ValidatesNumericalityTest < ActiveSupport::TestCase
0
   NIL = [nil]
0
   BLANK = ["", " ", " \t \r \n"]
0
   BIGDECIMAL_STRINGS = %w(12345678901234567890.1234567890) # 30 significent digits
...
5
6
7
8
 
9
10
11
...
40
41
42
43
 
44
45
46
...
72
73
74
75
 
76
77
78
...
118
119
120
121
 
122
123
124
...
5
6
7
 
8
9
10
11
...
40
41
42
 
43
44
45
46
...
72
73
74
 
75
76
77
78
...
118
119
120
 
121
122
123
124
0
@@ -5,7 +5,7 @@ require 'fixtures/author'
0
 require 'fixtures/tagging'
0
 require 'fixtures/comment'
0
 
0
-class XmlSerializationTest < Test::Unit::TestCase
0
+class XmlSerializationTest < ActiveSupport::TestCase
0
   def test_should_serialize_default_root
0
     @xml = Contact.new.to_xml
0
     assert_match %r{^<contact>},  @xml
0
@@ -40,7 +40,7 @@ class XmlSerializationTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class DefaultXmlSerializationTest < Test::Unit::TestCase
0
+class DefaultXmlSerializationTest < ActiveSupport::TestCase
0
   def setup
0
     @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false, :preferences => { :gem => 'ruby' }).to_xml
0
   end
0
@@ -72,7 +72,7 @@ class DefaultXmlSerializationTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class NilXmlSerializationTest < Test::Unit::TestCase
0
+class NilXmlSerializationTest < ActiveSupport::TestCase
0
   def setup
0
     @xml = Contact.new.to_xml(:root => 'xml_contact')
0
   end
0
@@ -118,7 +118,7 @@ class NilXmlSerializationTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
-class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase
0
+class DatabaseConnectedXmlSerializationTest < ActiveSupport::TestCase
0
   fixtures :authors, :posts
0
   # to_xml used to mess with the hash the user provided which
0
   # caused the builder to be reused.  This meant the document kept
...
1
2
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
0
@@ -1,5 +1,9 @@
0
 *SVN*
0
 
0
+* Continue evolution toward ActiveSupport::TestCase.  #10679 [Josh Peek]
0
+
0
+* 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]
0
+
0
 * Added ActiveSupport::Gzip.decompress/compress(source) as an easy wrapper for Zlib [Tobias Luetke]
0
 
0
 * Included MemCache-Client to make the improved ActiveSupport::Cache::MemCacheStore work out of the box [Bob Cottrell, Eric Hodel]
...
49
50
51
52
53
54
...
49
50
51
 
 
 
0
@@ -49,6 +49,3 @@ require 'active_support/json'
0
 require 'active_support/multibyte'
0
 
0
 require 'active_support/base64'
0
-
0
-require 'active_support/testing'
0
-
...
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
 
...
1
2
3
4
5
6
7
8
9
10
11
 
12
 
13
14
0
@@ -1,5 +1,13 @@
0
+require 'test/unit/testcase'
0
+require 'active_support/testing/setup_and_teardown'
0
+require 'active_support/testing/default'
0
+
0
+# TODO: move to core_ext
0
+class Test::Unit::TestCase #:nodoc:
0
+  include ActiveSupport::Testing::SetupAndTeardown
0
+end
0
+
0
 module ActiveSupport
0
   class TestCase < Test::Unit::TestCase
0
-    include ActiveSupport::Testing::Default
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
1
2
3
4
5
6
7
 
 
 
8
9
10
11
12
...
1
2
 
 
 
 
 
3
4
5
6
7
8
9
 
0
@@ -1,12 +1,9 @@
0
 module ActiveSupport
0
   module Testing
0
-    module Default
0
-      def run(*args)
0
-        #method_name appears to be a symbol on 1.8.4 and a string on 1.8.6
0
-        return if @method_name.to_s == "default_test"
0
-        super
0
+    module Default #:nodoc:
0
+      # Placeholder so test/unit ignores test cases without any tests.
0
+      def default_test
0
       end
0
     end
0
   end
0
 end
0
-
...
72
73
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
0
@@ -72,3 +72,49 @@ end
0
 
0
 class AlsoDoingNothingTest < ActiveSupport::TestCase
0
 end
0
+
0
+# Setup and teardown callbacks.
0
+class SetupAndTeardownTest < Test::Unit::TestCase
0
+  setup :reset_callback_record, :foo
0
+  teardown :foo, :sentinel, :foo
0
+
0
+  def test_inherited_setup_callbacks
0
+    assert_equal [:reset_callback_record, :foo], self.class.setup_callback_chain
0
+    assert_equal [:foo], @called_back
0
+    assert_equal [:foo, :sentinel, :foo], self.class.teardown_callback_chain
0
+  end
0
+
0
+  protected
0
+    def reset_callback_record
0
+      @called_back = []
0
+    end
0
+
0
+    def foo
0
+      @called_back << :foo
0
+    end
0
+
0
+    def sentinel
0
+      assert_equal [:foo, :foo], @called_back
0
+    end
0
+end
0
+
0
+
0
+class SubclassSetupAndTeardownTest < SetupAndTeardownTest
0
+  setup :bar
0
+  teardown :bar
0
+
0
+  def test_inherited_setup_callbacks
0
+    assert_equal [:reset_callback_record, :foo, :bar], self.class.setup_callback_chain
0
+    assert_equal [:foo, :bar], @called_back
0
+    assert_equal [:foo, :sentinel, :foo, :bar], self.class.teardown_callback_chain
0
+  end
0
+
0
+  protected
0
+    def bar
0
+      @called_back << :bar
0
+    end
0
+
0
+    def sentinel
0
+      assert_equal [:foo, :bar, :bar, :foo], @called_back
0
+    end
0
+end

Comments