aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/test_case.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-06-12 18:22:30 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-12 18:22:30 -0700
commitd62382afa39d7ea413b24cf33a6dbb55d8cc1f1c (patch)
tree5f6a7ed9c1c7ca63703fe77aef125bb93425beb6 /activesupport/lib/active_support/test_case.rb
parent579086047e4989a95533cd61d4ef1002239dd784 (diff)
downloadrails-d62382afa39d7ea413b24cf33a6dbb55d8cc1f1c.tar.gz
rails-d62382afa39d7ea413b24cf33a6dbb55d8cc1f1c.tar.bz2
rails-d62382afa39d7ea413b24cf33a6dbb55d8cc1f1c.zip
Ruby 1.9 compat: instance_methods are symbols instead of strings. Use the quicker instance_method(sym) rescue false check.
Diffstat (limited to 'activesupport/lib/active_support/test_case.rb')
-rw-r--r--activesupport/lib/active_support/test_case.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index d450cc117d..2fd02d5313 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -9,13 +9,14 @@ end
module ActiveSupport
class TestCase < Test::Unit::TestCase
- # test "verify something" do
+ # test "verify something" do
# ...
- # end
+ # 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)
+ 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
define_method(test_name, &block)
end
end
-end \ No newline at end of file
+end