From 8f92edb2b4b6beb5c778283be7cbcef6bf7e596c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?=
 <rafaelmfranca@gmail.com>
Date: Wed, 7 Jan 2015 00:58:49 -0300
Subject: Remove hard dependency on test-unit

Instead show a error message asking users to add the gem to their
Gemfile if test-unit could not be loaded.
---
 activesupport/activesupport.gemspec                   | 1 -
 activesupport/lib/active_support/test_case.rb         | 6 +++++-
 activesupport/lib/active_support/testing/isolation.rb | 7 ++++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

(limited to 'activesupport')

diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec
index f3c22871e5..e131ca7d68 100644
--- a/activesupport/activesupport.gemspec
+++ b/activesupport/activesupport.gemspec
@@ -22,5 +22,4 @@ Gem::Specification.new do |s|
 
   s.add_dependency('i18n',       '~> 0.6', '>= 0.6.4')
   s.add_dependency('multi_json', '~> 1.0')
-  s.add_dependency('test-unit',  '~> 3.0')
 end
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index 573736ede7..f0f83a747c 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -1,4 +1,8 @@
-require 'test/unit/testcase'
+begin
+  require 'test/unit/testcase'
+rescue LoadError => e
+  raise LoadError, "Please add test-unit gem to your Gemfile: `gem 'test-unit', '~> 3.0'` (#{e.message})", e.backtrace
+end
 require 'active_support/testing/setup_and_teardown'
 require 'active_support/testing/assertions'
 require 'active_support/testing/deprecation'
diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb
index 77c04758ba..d762522d29 100644
--- a/activesupport/lib/active_support/testing/isolation.rb
+++ b/activesupport/lib/active_support/testing/isolation.rb
@@ -156,7 +156,12 @@ end
 
 # Only in subprocess for windows / jruby.
 if ENV['ISOLATION_TEST']
-  require "test/unit/collector/objectspace"
+  begin
+    require "test/unit/collector/objectspace"
+  rescue LoadError => e
+    raise LoadError, "Please add test-unit gem to your Gemfile: `gem 'test-unit', '~> 3.0'` (#{e.message})", e.backtrace
+  end
+
   class Test::Unit::Collector::ObjectSpace
     def include?(test)
       super && test.method_name == ENV['ISOLATION_TEST']
-- 
cgit v1.2.3