Permalink
Browse files

Extract test method declaration

  • Loading branch information...
1 parent 728606d commit ae9581e0f3961a8a9754db6588b24200d4c443a5 @jeremy jeremy committed Nov 7, 2008
Showing with 21 additions and 0 deletions.
  1. +21 −0 activesupport/lib/active_support/testing/declarative.rb
@@ -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

0 comments on commit ae9581e

Please sign in to comment.