From 6ffb29d24e05abbd9ffe3ea974140d6c70221807 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 12 Aug 2014 19:30:05 +0900 Subject: users_dont_suck_but_only_we_suck_and_only_our_tests_are_order_dependent! Calling ActiveSupport::TestCase.i_suck_and_my_tests_are_order_dependent! in AS::TestCase makes everyone's tests order dependent, which should never be done by the framework. --- activesupport/test/abstract_unit.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index 7ffcae6007..e29a248aa0 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -38,3 +38,8 @@ def jruby_skip(message = '') end require 'mocha/setup' # FIXME: stop using mocha + +# FIXME: we have tests that depend on run order, we should fix that and +# remove this method call. +require 'active_support/test_case' +ActiveSupport::TestCase.i_suck_and_my_tests_are_order_dependent! -- cgit v1.2.3 From e81f3c210eca074ed6227bd1c40835d44761c09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 12 Aug 2014 10:51:41 -0300 Subject: Nobody sucks so nobody should call this awful method name --- activesupport/test/abstract_unit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/test') diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index e29a248aa0..52fbaf8a85 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -42,4 +42,4 @@ require 'mocha/setup' # FIXME: stop using mocha # FIXME: we have tests that depend on run order, we should fix that and # remove this method call. require 'active_support/test_case' -ActiveSupport::TestCase.i_suck_and_my_tests_are_order_dependent! +ActiveSupport::TestCase.my_tests_are_order_dependent! -- cgit v1.2.3 From fe873dfae2882ad8ae20100af497b9e87202070c Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 13 Aug 2014 19:08:50 +0900 Subject: Duplicated method in the test helper --- activesupport/test/dependencies_test.rb | 7 ------- 1 file changed, 7 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index a013aadd67..03e79fa25e 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -990,11 +990,4 @@ class DependenciesTest < ActiveSupport::TestCase ensure ActiveSupport::Dependencies.hook! end - -private - def remove_constants(*constants) - constants.each do |constant| - Object.send(:remove_const, constant) if Object.const_defined?(constant) - end - end end -- cgit v1.2.3 From 6e440a014709f8f5ffd2fb2c72ddf7de9f3f456a Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 13 Aug 2014 19:37:12 +0900 Subject: Reset ActiveSupport::Dependencies.mechanism to make tests order independent --- activesupport/test/dependencies_test.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 03e79fa25e..5fc3de651a 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -47,18 +47,22 @@ class DependenciesTest < ActiveSupport::TestCase end def test_tracking_loaded_files - require_dependency 'dependencies/service_one' - require_dependency 'dependencies/service_two' - assert_equal 2, ActiveSupport::Dependencies.loaded.size + with_loading do + require_dependency 'dependencies/service_one' + require_dependency 'dependencies/service_two' + assert_equal 2, ActiveSupport::Dependencies.loaded.size + end ensure Object.send(:remove_const, :ServiceOne) if Object.const_defined?(:ServiceOne) Object.send(:remove_const, :ServiceTwo) if Object.const_defined?(:ServiceTwo) end def test_tracking_identical_loaded_files - require_dependency 'dependencies/service_one' - require_dependency 'dependencies/service_one' - assert_equal 1, ActiveSupport::Dependencies.loaded.size + with_loading do + require_dependency 'dependencies/service_one' + require_dependency 'dependencies/service_one' + assert_equal 1, ActiveSupport::Dependencies.loaded.size + end ensure Object.send(:remove_const, :ServiceOne) if Object.const_defined?(:ServiceOne) end -- cgit v1.2.3 From cbde413df3839e06dd14e3c220e9800af91e83ab Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 13 Aug 2014 19:44:50 +0900 Subject: AS tests are now order_independent! --- activesupport/test/abstract_unit.rb | 5 ----- 1 file changed, 5 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index 52fbaf8a85..7ffcae6007 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -38,8 +38,3 @@ def jruby_skip(message = '') end require 'mocha/setup' # FIXME: stop using mocha - -# FIXME: we have tests that depend on run order, we should fix that and -# remove this method call. -require 'active_support/test_case' -ActiveSupport::TestCase.my_tests_are_order_dependent! -- cgit v1.2.3