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

Extract test method declaration

This commit is contained in:
Jeremy Kemper 2008-11-07 13:25:40 -05:00
parent 728606df91
commit ae9581e0f3

View file

@ -0,0 +1,21 @@
module ActiveSupport
module Testing
module Declarative
# test "verify something" do
# ...
# end
def test(name, &block)
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
if block_given?
define_method(test_name, &block)
else
define_method(test_name) do
flunk "No implementation provided for #{name}"
end
end
end
end
end
end