mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ruby 1.9 compat: instance_methods are symbols instead of strings. Use the quicker instance_method(sym) rescue false check.
This commit is contained in:
parent
579086047e
commit
d62382afa3
1 changed files with 6 additions and 5 deletions
|
@ -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
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue