Class: ActiveSupport::TestCase

Inherits:
Test::Unit::TestCase show all
Defined in:
lib/active_support/test_case.rb

Constant Summary

Constants included from ActiveSupport::Testing::SetupAndTeardown

ActiveSupport::Testing::SetupAndTeardown::PASSTHROUGH_EXCEPTIONS

Class Method Summary collapse

Methods included from ActiveSupport::Testing::SetupAndTeardown

included, #run_with_callbacks_and_miniunit, #run_with_callbacks_and_mocha, #run_with_callbacks_and_testunit

Methods included from Deprecation::Assertions

#assert_deprecated, #assert_not_deprecated

Class Method Details

.test(name, &block) ⇒ Object

test “verify something” do

...

end



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/active_support/test_case.rb', line 11

def self.test(name, &block)
  test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
  defined = instance_method(test_name) rescue false
  raise "#{test_name} is already defined in #{self}" if defined
  if block_given?
    define_method(test_name, &block)
  else
    define_method(test_name) do
      flunk "No implementation provided for #{name}"
    end
  end
end