Skip to content
This repository
Browse code

Revert "scrub instance variables from test cases on teardown"

This reverts commit b5cf2b4.
  • Loading branch information...
commit c545331f9e3cd8eb1ee2fca266c98b7d62b92f3e 1 parent cd0ecff
Jamis Buck authored January 19, 2011
2  activesupport/lib/active_support/test_case.rb
@@ -3,7 +3,6 @@
3 3
 require 'active_support/testing/assertions'
4 4
 require 'active_support/testing/deprecation'
5 5
 require 'active_support/testing/declarative'
6  
-require 'active_support/testing/garbage_collection'
7 6
 
8 7
 begin
9 8
   gem 'mocha', ">= 0.9.7"
@@ -37,6 +36,5 @@ class TestCase < ::Test::Unit::TestCase
37 36
     include ActiveSupport::Testing::Assertions
38 37
     include ActiveSupport::Testing::Deprecation
39 38
     extend ActiveSupport::Testing::Declarative
40  
-    include ActiveSupport::Testing::GarbageCollection
41 39
   end
42 40
 end
19  activesupport/lib/active_support/testing/garbage_collection.rb
... ...
@@ -1,19 +0,0 @@
1  
-module ActiveSupport
2  
-  module Testing
3  
-    module GarbageCollection
4  
-      def self.included(base)
5  
-        base.teardown :scrub_leftover_instance_variables
6  
-      end
7  
-
8  
-      private
9  
-
10  
-      RESERVED_INSTANCE_VARIABLES = %w(@test_passed @passed @method_name @__name__ @_result).map(&:to_sym)
11  
-
12  
-      def scrub_leftover_instance_variables
13  
-        (instance_variables.map(&:to_sym) - RESERVED_INSTANCE_VARIABLES).each do |var|
14  
-          remove_instance_variable(var)
15  
-        end
16  
-      end
17  
-    end
18  
-  end
19  
-end
18  activesupport/test/test_case_test.rb
@@ -74,23 +74,5 @@ def test_true; assert true end
74 74
 
75 75
       assert_match %r{oh noes}, exception.message
76 76
     end
77  
-
78  
-    def test_teardown_should_scrub_instance_variables
79  
-      tc = Class.new(TestCase) do
80  
-        def test_true; @alpha = "a"; assert_equal "a", @alpha; end
81  
-      end
82  
-
83  
-      test_name = 'test_true'
84  
-      fr = FakeRunner.new
85  
-
86  
-      test = tc.new test_name
87  
-      test.run(fr) {}
88  
-
89  
-      passed_var = IS_MINITEST ? :@passed : :@test_passed
90  
-      ivars = test.instance_variables.map(&:to_sym)
91  
-
92  
-      assert ivars.include?(passed_var), "#{passed_var} should not have been scrubbed"
93  
-      assert !ivars.include?(:@alpha), "@alpha should have been scrubbed"
94  
-    end
95 77
   end
96 78
 end
4  activesupport/test/test_test.rb
@@ -143,7 +143,7 @@ class SetupAndTeardownTest < ActiveSupport::TestCase
143 143
   def test_inherited_setup_callbacks
144 144
     assert_equal [:reset_callback_record, :foo], self.class.setup_callback_chain.map(&:method)
145 145
     assert_equal [:foo], @called_back
146  
-    assert_equal [:scrub_leftover_instance_variables, :foo, :sentinel, :foo], self.class.teardown_callback_chain.map(&:method)
  146
+    assert_equal [:foo, :sentinel, :foo], self.class.teardown_callback_chain.map(&:method)
147 147
   end
148 148
 
149 149
   def setup
@@ -174,7 +174,7 @@ class SubclassSetupAndTeardownTest < SetupAndTeardownTest
174 174
   def test_inherited_setup_callbacks
175 175
     assert_equal [:reset_callback_record, :foo, :bar], self.class.setup_callback_chain.map(&:method)
176 176
     assert_equal [:foo, :bar], @called_back
177  
-    assert_equal [:scrub_leftover_instance_variables, :foo, :sentinel, :foo, :bar], self.class.teardown_callback_chain.map(&:method)
  177
+    assert_equal [:foo, :sentinel, :foo, :bar], self.class.teardown_callback_chain.map(&:method)
178 178
   end
179 179
 
180 180
   protected

0 notes on commit c545331

Please sign in to comment.
Something went wrong with that request. Please try again.