instance method around

Ruby on Rails edge

Since edge

Signature

around(*args, &block)

Add a callback, which runs between the TestCase#setup callbacks and the TestCase#teardown callbacks. Yields the test class instance and the test case to the block:

class ClientTest < ActiveSupport::TestCase
  around do |test_case, block|
    # do client setup
    block.call
    # do client teardown
  end
end

Code after a failing test yielded by the block argument will still be executed.

Parameters

args rest
block block
Source
# File activesupport/lib/active_support/testing/setup_and_teardown.rb, line 62
        def around(*args, &block)
          set_callback(:test, :around, *args, &block)

          include AroundCallbackSupport unless self < AroundCallbackSupport
        end

Defined in activesupport/lib/active_support/testing/setup_and_teardown.rb line 62 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Testing::SetupAndTeardown::ClassMethods

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close