Permalink
Browse files

Ruby 1.9 compat: instance_methods are symbols instead of strings. Use…

… the quicker instance_method(sym) rescue false check.
  • Loading branch information...
1 parent 5790860 commit d62382afa39d7ea413b24cf33a6dbb55d8cc1f1c @jeremy jeremy committed Jun 13, 2008
Showing with 6 additions and 5 deletions.
  1. +6 −5 activesupport/lib/active_support/test_case.rb
@@ -9,13 +9,14 @@ class Test::Unit::TestCase #:nodoc:
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
+end

0 comments on commit d62382a

Please sign in to comment.