2012-07-04 14:16:21 -04:00
|
|
|
gem 'minitest' # make sure we get the gem, not stdlib
|
2013-05-22 12:51:01 -04:00
|
|
|
require 'minitest'
|
2012-09-26 14:16:43 -04:00
|
|
|
require 'active_support/testing/tagged_logging'
|
2008-11-23 17:48:36 -05:00
|
|
|
require 'active_support/testing/setup_and_teardown'
|
|
|
|
require 'active_support/testing/assertions'
|
|
|
|
require 'active_support/testing/deprecation'
|
2012-12-28 12:06:10 -05:00
|
|
|
require 'active_support/testing/declarative'
|
2009-06-30 15:00:50 -04:00
|
|
|
require 'active_support/testing/isolation'
|
2012-09-24 15:44:49 -04:00
|
|
|
require 'active_support/testing/constant_lookup'
|
2010-03-17 16:44:24 -04:00
|
|
|
require 'active_support/core_ext/kernel/reporting'
|
2012-07-09 16:11:05 -04:00
|
|
|
require 'active_support/deprecation'
|
2008-11-23 17:48:36 -05:00
|
|
|
|
2012-11-12 04:34:21 -05:00
|
|
|
begin
|
|
|
|
silence_warnings { require 'mocha/setup' }
|
|
|
|
rescue LoadError
|
|
|
|
end
|
|
|
|
|
2013-05-06 20:38:45 -04:00
|
|
|
module Minitest # :nodoc:
|
|
|
|
class << self
|
|
|
|
remove_method :__run
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.__run reporter, options # :nodoc:
|
|
|
|
# FIXME: MT5's runnables is not ordered. This is needed because
|
2013-10-28 05:08:55 -04:00
|
|
|
# we have tests with cross-class order-dependent bugs.
|
2013-05-06 20:38:45 -04:00
|
|
|
suites = Runnable.runnables.sort_by { |ts| ts.name.to_s }
|
|
|
|
|
|
|
|
parallel, serial = suites.partition { |s| s.test_order == :parallel }
|
|
|
|
|
|
|
|
ParallelEach.new(parallel).map { |suite| suite.run reporter, options } +
|
|
|
|
serial.map { |suite| suite.run reporter, options }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-11-22 22:18:30 -05:00
|
|
|
module ActiveSupport
|
2013-05-06 20:38:45 -04:00
|
|
|
class TestCase < ::Minitest::Test
|
|
|
|
Assertion = Minitest::Assertion
|
|
|
|
|
|
|
|
alias_method :method_name, :name
|
2008-11-07 12:45:48 -05:00
|
|
|
|
2009-05-20 19:52:56 -04:00
|
|
|
$tags = {}
|
|
|
|
def self.for_tag(tag)
|
|
|
|
yield if $tags[tag]
|
|
|
|
end
|
|
|
|
|
2013-02-23 19:22:45 -05:00
|
|
|
# FIXME: we have tests that depend on run order, we should fix that and
|
|
|
|
# remove this method.
|
2012-01-05 19:51:37 -05:00
|
|
|
def self.test_order # :nodoc:
|
|
|
|
:sorted
|
|
|
|
end
|
|
|
|
|
2012-09-26 14:16:43 -04:00
|
|
|
include ActiveSupport::Testing::TaggedLogging
|
2008-11-07 12:45:48 -05:00
|
|
|
include ActiveSupport::Testing::SetupAndTeardown
|
|
|
|
include ActiveSupport::Testing::Assertions
|
2008-11-23 16:11:07 -05:00
|
|
|
include ActiveSupport::Testing::Deprecation
|
2012-12-28 12:06:10 -05:00
|
|
|
extend ActiveSupport::Testing::Declarative
|
2012-01-05 18:46:17 -05:00
|
|
|
|
|
|
|
# test/unit backwards compatibility methods
|
|
|
|
alias :assert_raise :assert_raises
|
2012-12-28 18:49:41 -05:00
|
|
|
alias :assert_not_empty :refute_empty
|
2012-01-05 18:46:17 -05:00
|
|
|
alias :assert_not_equal :refute_equal
|
2012-12-28 18:49:41 -05:00
|
|
|
alias :assert_not_in_delta :refute_in_delta
|
|
|
|
alias :assert_not_in_epsilon :refute_in_epsilon
|
|
|
|
alias :assert_not_includes :refute_includes
|
|
|
|
alias :assert_not_instance_of :refute_instance_of
|
|
|
|
alias :assert_not_kind_of :refute_kind_of
|
2012-01-05 18:46:17 -05:00
|
|
|
alias :assert_no_match :refute_match
|
2012-12-28 18:49:41 -05:00
|
|
|
alias :assert_not_nil :refute_nil
|
|
|
|
alias :assert_not_operator :refute_operator
|
|
|
|
alias :assert_not_predicate :refute_predicate
|
|
|
|
alias :assert_not_respond_to :refute_respond_to
|
2012-01-06 17:04:09 -05:00
|
|
|
alias :assert_not_same :refute_same
|
2012-01-05 18:46:17 -05:00
|
|
|
|
2012-12-05 01:11:54 -05:00
|
|
|
# Fails if the block raises an exception.
|
2012-06-19 16:08:13 -04:00
|
|
|
#
|
|
|
|
# assert_nothing_raised do
|
|
|
|
# ...
|
|
|
|
# end
|
2012-01-05 18:46:17 -05:00
|
|
|
def assert_nothing_raised(*args)
|
|
|
|
yield
|
|
|
|
end
|
2008-11-07 12:45:48 -05:00
|
|
|
end
|
2008-11-22 22:18:30 -05:00
|
|
|
end
|