test_case.rb 1.5 KB
Newer Older
1
gem 'minitest' # make sure we get the gem, not stdlib
2
require 'minitest/spec'
3 4 5
require 'active_support/testing/setup_and_teardown'
require 'active_support/testing/assertions'
require 'active_support/testing/deprecation'
6
require 'active_support/testing/isolation'
7
require 'active_support/testing/mocha_module'
8
require 'active_support/core_ext/kernel/reporting'
9

10
module ActiveSupport
11 12
  class TestCase < ::MiniTest::Spec

13 14
    include ActiveSupport::Testing::MochaModule

15 16 17 18 19
    # Use AS::TestCase for the base class when describing a model
    register_spec_type(self) do |desc|
      desc < ActiveRecord::Model
    end

V
Vishnu Atrai 已提交
20
    Assertion = MiniTest::Assertion
21
    alias_method :method_name, :__name__
22

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

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

34 35
    include ActiveSupport::Testing::SetupAndTeardown
    include ActiveSupport::Testing::Assertions
36
    include ActiveSupport::Testing::Deprecation
37 38 39 40

    class << self
      alias :test :it
    end
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 50 51 52 53
    # Fails if the block raises an exception.
    #
    #   assert_nothing_raised do
    #     ...
    #   end
54 55 56
    def assert_nothing_raised(*args)
      yield
    end
57
  end
58
end