diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-06-12 20:10:38 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-06-12 20:10:38 -0500 |
commit | f74ba37f4e4175d5a1b31da59d161b0020b58e94 (patch) | |
tree | fee4f0c757d26e5c0355f7ed5c086b1f81c9617a /activesupport | |
parent | 048ac3604cd46479002eaf7b1bb32770289580fc (diff) | |
download | rails-f74ba37f4e4175d5a1b31da59d161b0020b58e94.tar.gz rails-f74ba37f4e4175d5a1b31da59d161b0020b58e94.tar.bz2 rails-f74ba37f4e4175d5a1b31da59d161b0020b58e94.zip |
Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields]
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/test_case.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index d0f13afdaa..0272b08215 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *Edge* +* Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields] + * Added Object#present? which is equivalent to !Object#blank? [DHH] * Added Enumberable#several? to encapsulate collection.size > 1 [DHH] 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 |