Skip to content

Commit fec6f1b

Browse files
committed
Merge pull request rails#4360 from rafaelfranca/patch-1
Remove more references to Test::Unit
2 parents 1c09c29 + 185aa82 commit fec6f1b

File tree

4 files changed

+15
-50
lines changed

4 files changed

+15
-50
lines changed

activemodel/test/cases/naming_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def test_i18n_key
210210
end
211211
end
212212

213-
class NamingHelpersTest < Test::Unit::TestCase
213+
class NamingHelpersTest < ActiveModel::TestCase
214214
def setup
215215
@klass = Contact
216216
@record = @klass.new
@@ -276,7 +276,7 @@ def method_missing(method, *args)
276276
end
277277
end
278278

279-
class NameWithAnonymousClassTest < Test::Unit::TestCase
279+
class NameWithAnonymousClassTest < ActiveModel::TestCase
280280
def test_anonymous_class_without_name_argument
281281
assert_raises(ArgumentError) do
282282
ActiveModel::Name.new(Class.new)

activesupport/lib/active_support/backtrace_cleaner.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module ActiveSupport
2-
# Backtraces often include many lines that are not relevant for the context under review. This makes it hard to find the
2+
# Backtraces often include many lines that are not relevant for the context under review. This makes it hard to find the
33
# signal amongst the backtrace noise, and adds debugging time. With a BacktraceCleaner, filters and silencers are used to
44
# remove the noisy lines, so that only the most relevant lines remain.
55
#
66
# Filters are used to modify lines of data, while silencers are used to remove lines entirely. The typical filter use case
7-
# is to remove lengthy path information from the start of each line, and view file paths relevant to the app directory
8-
# instead of the file system root. The typical silencer use case is to exclude the output of a noisy library from the
7+
# is to remove lengthy path information from the start of each line, and view file paths relevant to the app directory
8+
# instead of the file system root. The typical silencer use case is to exclude the output of a noisy library from the
99
# backtrace, so that you can focus on the rest.
1010
#
1111
# ==== Example:
@@ -15,9 +15,9 @@ module ActiveSupport
1515
# bc.add_silencer { |line| line =~ /mongrel|rubygems/ }
1616
# bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems
1717
#
18-
# To reconfigure an existing BacktraceCleaner (like the default one in Rails) and show as much data as possible, you can
19-
# always call <tt>BacktraceCleaner#remove_silencers!</tt>, which will restore the backtrace to a pristine state. If you
20-
# need to reconfigure an existing BacktraceCleaner so that it does not filter or modify the paths of any lines of the
18+
# To reconfigure an existing BacktraceCleaner (like the default one in Rails) and show as much data as possible, you can
19+
# always call <tt>BacktraceCleaner#remove_silencers!</tt>, which will restore the backtrace to a pristine state. If you
20+
# need to reconfigure an existing BacktraceCleaner so that it does not filter or modify the paths of any lines of the
2121
# backtrace, you can call BacktraceCleaner#remove_filters! These two methods will give you a completely untouched backtrace.
2222
#
2323
# Inspired by the Quiet Backtrace gem by Thoughtbot.
@@ -50,7 +50,7 @@ def add_filter(&block)
5050
@filters << block
5151
end
5252

53-
# Adds a silencer from the block provided. If the silencer returns true for a given line, it will be excluded from
53+
# Adds a silencer from the block provided. If the silencer returns true for a given line, it will be excluded from
5454
# the clean backtrace.
5555
#
5656
# Example:

railties/lib/rails/test_help.rb

+6-13
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,14 @@
77
require 'action_controller/test_case'
88
require 'action_dispatch/testing/integration'
99

10-
if defined?(Test::Unit::Util::BacktraceFilter) && ENV['BACKTRACE'].nil?
11-
require 'rails/backtrace_cleaner'
12-
Test::Unit::Util::BacktraceFilter.module_eval { include Rails::BacktraceFilterForTestUnit }
13-
end
14-
15-
if defined?(MiniTest)
16-
# Enable turn if it is available
17-
begin
18-
require 'turn'
10+
# Enable turn if it is available
11+
begin
12+
require 'turn'
1913

20-
if MiniTest::Unit.respond_to?(:use_natural_language_case_names=)
21-
MiniTest::Unit.use_natural_language_case_names = true
22-
end
23-
rescue LoadError
14+
if MiniTest::Unit.respond_to?(:use_natural_language_case_names=)
15+
MiniTest::Unit.use_natural_language_case_names = true
2416
end
17+
rescue LoadError
2518
end
2619

2720
if defined?(ActiveRecord::Base)

railties/test/backtrace_cleaner_test.rb

-28
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
11
require 'abstract_unit'
22
require 'rails/backtrace_cleaner'
33

4-
if defined? Test::Unit::Util::BacktraceFilter
5-
class TestWithBacktrace
6-
include Test::Unit::Util::BacktraceFilter
7-
include Rails::BacktraceFilterForTestUnit
8-
end
9-
10-
class BacktraceCleanerFilterTest < ActiveSupport::TestCase
11-
def setup
12-
@test = TestWithBacktrace.new
13-
@backtrace = [ './test/rails/benchmark_test.rb', './test/rails/dependencies.rb', '/opt/local/lib/ruby/kernel.rb' ]
14-
end
15-
16-
test "test with backtrace should use the rails backtrace cleaner to clean" do
17-
Rails.stubs(:backtrace_cleaner).returns(stub(:clean))
18-
Rails.backtrace_cleaner.expects(:clean).with(@backtrace, nil)
19-
@test.send(:filter_backtrace, @backtrace)
20-
end
21-
22-
test "filter backtrace should have the same arity as Test::Unit::Util::BacktraceFilter" do
23-
assert_nothing_raised do
24-
@test.send(:filter_backtrace, @backtrace, '/opt/local/lib')
25-
end
26-
end
27-
end
28-
else
29-
$stderr.puts 'No BacktraceFilter for minitest'
30-
end
31-
324
if defined? Gem
335
class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase
346
def setup

0 commit comments

Comments
 (0)