From f74ba37f4e4175d5a1b31da59d161b0020b58e94 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 12 Jun 2008 20:10:38 -0500 Subject: Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields] --- activesupport/lib/active_support/test_case.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index 67cde1556c..d450cc117d 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -9,5 +9,13 @@ end module ActiveSupport class TestCase < Test::Unit::TestCase + # test "verify something" do + # ... + # end + def self.test(name, &block) + test_name = "test_#{name.gsub(/[\s]/,'_')}".to_sym + raise "#{test_name} is already defined in #{self}" if self.instance_methods.include?(test_name.to_s) + define_method(test_name, &block) + end end -end +end \ No newline at end of file -- cgit v1.2.3