Browse files

add documentation for `ActiveSupport::Testing::SetupAndTeardown`.

  • Loading branch information...
1 parent 33c1b46 commit b6a711f5f44d86554001ddd2ce52f19039073bd2 @senny senny committed Jun 19, 2013
Showing with 17 additions and 2 deletions.
  1. +17 −2 activesupport/lib/active_support/testing/setup_and_teardown.rb
View
19 activesupport/lib/active_support/testing/setup_and_teardown.rb
@@ -3,6 +3,19 @@
module ActiveSupport
module Testing
+ # Adds support for +setup+ and +teardown+ callbacks.
+ # These callbacks serve as a replacement to overwriting the
+ # <tt>#setup</tt> and <tt>#teardown</tt> methods of your TestCase.
+ #
+ # class ExampleTest < ActiveSupport::TestCase
+ # setup do
+ # # ...
+ # end
+ #
+ # teardown do
+ # # ...
+ # end
+ # end
module SetupAndTeardown
extend ActiveSupport::Concern
@@ -12,21 +25,23 @@ module SetupAndTeardown
end
module ClassMethods
+ # Add a callback, which runs before <tt>TestCase#setup</tt>.
def setup(*args, &block)
set_callback(:setup, :before, *args, &block)
end
+ # Add a callback, which runs after <tt>TestCase#teardown</tt>.
def teardown(*args, &block)
set_callback(:teardown, :after, *args, &block)
end
end
- def before_setup
+ def before_setup # :nodoc:
super
run_callbacks :setup
end
- def after_teardown
+ def after_teardown # :nodoc:
run_callbacks :teardown
super
end

0 comments on commit b6a711f

Please sign in to comment.