test_case.rb 1.7 KB
Newer Older
1
gem 'minitest' # make sure we get the gem, not stdlib
2
require 'minitest/unit'
3
require 'active_support/testing/tagged_logging'
4 5 6
require 'active_support/testing/setup_and_teardown'
require 'active_support/testing/assertions'
require 'active_support/testing/deprecation'
7
require 'active_support/testing/pending'
8
require 'active_support/testing/declarative'
9
require 'active_support/testing/isolation'
10
require 'active_support/testing/constant_lookup'
11
require 'active_support/core_ext/kernel/reporting'
12
require 'active_support/deprecation'
13

14 15 16 17 18
begin
  silence_warnings { require 'mocha/setup' }
rescue LoadError
end

19
module ActiveSupport
20
  class TestCase < ::MiniTest::Unit::TestCase
V
Vishnu Atrai 已提交
21
    Assertion = MiniTest::Assertion
22
    alias_method :method_name, :__name__
23

24 25 26 27 28
    $tags = {}
    def self.for_tag(tag)
      yield if $tags[tag]
    end

29 30 31 32 33 34
    # FIXME: we have tests that depend on run order, we should fix that and
    # remove this method.
    def self.test_order # :nodoc:
      :sorted
    end

35
    include ActiveSupport::Testing::TaggedLogging
36 37
    include ActiveSupport::Testing::SetupAndTeardown
    include ActiveSupport::Testing::Assertions
38
    include ActiveSupport::Testing::Deprecation
39
    include ActiveSupport::Testing::Pending
40
    extend ActiveSupport::Testing::Declarative
41 42 43 44 45 46

    # test/unit backwards compatibility methods
    alias :assert_raise :assert_raises
    alias :assert_not_nil :refute_nil
    alias :assert_not_equal :refute_equal
    alias :assert_no_match :refute_match
A
Aaron Patterson 已提交
47
    alias :assert_not_same :refute_same
48

49
    # Fails if the block raises an exception.
50 51 52 53
    #
    #   assert_nothing_raised do
    #     ...
    #   end
54 55 56
    def assert_nothing_raised(*args)
      yield
    end
57
  end
58
end