aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-11-07 13:25:40 -0500
committerJeremy Kemper <jeremy@bitsweat.net>2008-11-07 13:25:40 -0500
commitae9581e0f3961a8a9754db6588b24200d4c443a5 (patch)
treea1aa8c2d85f401e77c6080c1e947ba16cd6ed226 /activesupport/lib
parent728606df9170aef6dbc2fcf43901b3e2d8368fcc (diff)
downloadrails-ae9581e0f3961a8a9754db6588b24200d4c443a5.tar.gz
rails-ae9581e0f3961a8a9754db6588b24200d4c443a5.tar.bz2
rails-ae9581e0f3961a8a9754db6588b24200d4c443a5.zip
Extract test method declaration
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/testing/declarative.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/testing/declarative.rb b/activesupport/lib/active_support/testing/declarative.rb
new file mode 100644
index 0000000000..cb6a5844eb
--- /dev/null
+++ b/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