Skip to content

Commit

Permalink
Ruby 1.9 compat: instance_methods are symbols instead of strings. Use…
Browse files Browse the repository at this point in the history
… the quicker instance_method(sym) rescue false check.
  • Loading branch information
jeremy committed Jun 13, 2008
1 parent 5790860 commit d62382a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions activesupport/lib/active_support/test_case.rb
Expand Up @@ -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.