1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

use method_defined? to check whether or not a method is defined

This commit is contained in:
Aaron Patterson 2014-03-12 13:34:07 -07:00
parent 81d08abccc
commit 28d05f0a80

View file

@ -34,7 +34,7 @@ module ActiveSupport
# end
def test(name, &block)
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
defined = instance_method(test_name) rescue false
defined = method_defined? test_name
raise "#{test_name} is already defined in #{self}" if defined
if block_given?
define_method(test_name, &block)