2012-12-28 12:06:10 -05:00
|
|
|
module ActiveSupport
|
|
|
|
module Testing
|
|
|
|
module Declarative
|
|
|
|
unless defined?(Spec)
|
2013-06-19 07:00:38 -04:00
|
|
|
# Helper to define a test method using a String. Under the hood, it replaces
|
|
|
|
# spaces with underscores and defines the test method.
|
|
|
|
#
|
|
|
|
# test "verify something" do
|
|
|
|
# ...
|
|
|
|
# end
|
2012-12-28 12:06:10 -05:00
|
|
|
def test(name, &block)
|
|
|
|
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
2014-03-12 16:34:07 -04:00
|
|
|
defined = method_defined? test_name
|
2012-12-28 12:06:10 -05:00
|
|
|
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
|
|
|
|
end
|