mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #4360 from rafaelfranca/patch-1
Remove more references to Test::Unit
This commit is contained in:
commit
fec6f1ba82
4 changed files with 15 additions and 50 deletions
|
@ -210,7 +210,7 @@ class NamingUsingRelativeModelNameTest < ActiveModel::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
class NamingHelpersTest < Test::Unit::TestCase
|
||||
class NamingHelpersTest < ActiveModel::TestCase
|
||||
def setup
|
||||
@klass = Contact
|
||||
@record = @klass.new
|
||||
|
@ -276,7 +276,7 @@ class NamingHelpersTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
class NameWithAnonymousClassTest < Test::Unit::TestCase
|
||||
class NameWithAnonymousClassTest < ActiveModel::TestCase
|
||||
def test_anonymous_class_without_name_argument
|
||||
assert_raises(ArgumentError) do
|
||||
ActiveModel::Name.new(Class.new)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
module ActiveSupport
|
||||
# Backtraces often include many lines that are not relevant for the context under review. This makes it hard to find the
|
||||
# Backtraces often include many lines that are not relevant for the context under review. This makes it hard to find the
|
||||
# signal amongst the backtrace noise, and adds debugging time. With a BacktraceCleaner, filters and silencers are used to
|
||||
# remove the noisy lines, so that only the most relevant lines remain.
|
||||
#
|
||||
# Filters are used to modify lines of data, while silencers are used to remove lines entirely. The typical filter use case
|
||||
# is to remove lengthy path information from the start of each line, and view file paths relevant to the app directory
|
||||
# instead of the file system root. The typical silencer use case is to exclude the output of a noisy library from the
|
||||
# is to remove lengthy path information from the start of each line, and view file paths relevant to the app directory
|
||||
# instead of the file system root. The typical silencer use case is to exclude the output of a noisy library from the
|
||||
# backtrace, so that you can focus on the rest.
|
||||
#
|
||||
# ==== Example:
|
||||
|
@ -15,9 +15,9 @@ module ActiveSupport
|
|||
# bc.add_silencer { |line| line =~ /mongrel|rubygems/ }
|
||||
# bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems
|
||||
#
|
||||
# To reconfigure an existing BacktraceCleaner (like the default one in Rails) and show as much data as possible, you can
|
||||
# always call <tt>BacktraceCleaner#remove_silencers!</tt>, which will restore the backtrace to a pristine state. If you
|
||||
# need to reconfigure an existing BacktraceCleaner so that it does not filter or modify the paths of any lines of the
|
||||
# To reconfigure an existing BacktraceCleaner (like the default one in Rails) and show as much data as possible, you can
|
||||
# always call <tt>BacktraceCleaner#remove_silencers!</tt>, which will restore the backtrace to a pristine state. If you
|
||||
# need to reconfigure an existing BacktraceCleaner so that it does not filter or modify the paths of any lines of the
|
||||
# backtrace, you can call BacktraceCleaner#remove_filters! These two methods will give you a completely untouched backtrace.
|
||||
#
|
||||
# Inspired by the Quiet Backtrace gem by Thoughtbot.
|
||||
|
@ -50,7 +50,7 @@ module ActiveSupport
|
|||
@filters << block
|
||||
end
|
||||
|
||||
# Adds a silencer from the block provided. If the silencer returns true for a given line, it will be excluded from
|
||||
# Adds a silencer from the block provided. If the silencer returns true for a given line, it will be excluded from
|
||||
# the clean backtrace.
|
||||
#
|
||||
# Example:
|
||||
|
|
|
@ -7,21 +7,14 @@ require 'active_support/test_case'
|
|||
require 'action_controller/test_case'
|
||||
require 'action_dispatch/testing/integration'
|
||||
|
||||
if defined?(Test::Unit::Util::BacktraceFilter) && ENV['BACKTRACE'].nil?
|
||||
require 'rails/backtrace_cleaner'
|
||||
Test::Unit::Util::BacktraceFilter.module_eval { include Rails::BacktraceFilterForTestUnit }
|
||||
end
|
||||
# Enable turn if it is available
|
||||
begin
|
||||
require 'turn'
|
||||
|
||||
if defined?(MiniTest)
|
||||
# Enable turn if it is available
|
||||
begin
|
||||
require 'turn'
|
||||
|
||||
if MiniTest::Unit.respond_to?(:use_natural_language_case_names=)
|
||||
MiniTest::Unit.use_natural_language_case_names = true
|
||||
end
|
||||
rescue LoadError
|
||||
if MiniTest::Unit.respond_to?(:use_natural_language_case_names=)
|
||||
MiniTest::Unit.use_natural_language_case_names = true
|
||||
end
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
if defined?(ActiveRecord::Base)
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
require 'abstract_unit'
|
||||
require 'rails/backtrace_cleaner'
|
||||
|
||||
if defined? Test::Unit::Util::BacktraceFilter
|
||||
class TestWithBacktrace
|
||||
include Test::Unit::Util::BacktraceFilter
|
||||
include Rails::BacktraceFilterForTestUnit
|
||||
end
|
||||
|
||||
class BacktraceCleanerFilterTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@test = TestWithBacktrace.new
|
||||
@backtrace = [ './test/rails/benchmark_test.rb', './test/rails/dependencies.rb', '/opt/local/lib/ruby/kernel.rb' ]
|
||||
end
|
||||
|
||||
test "test with backtrace should use the rails backtrace cleaner to clean" do
|
||||
Rails.stubs(:backtrace_cleaner).returns(stub(:clean))
|
||||
Rails.backtrace_cleaner.expects(:clean).with(@backtrace, nil)
|
||||
@test.send(:filter_backtrace, @backtrace)
|
||||
end
|
||||
|
||||
test "filter backtrace should have the same arity as Test::Unit::Util::BacktraceFilter" do
|
||||
assert_nothing_raised do
|
||||
@test.send(:filter_backtrace, @backtrace, '/opt/local/lib')
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
$stderr.puts 'No BacktraceFilter for minitest'
|
||||
end
|
||||
|
||||
if defined? Gem
|
||||
class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
|
|
Loading…
Reference in a new issue