Flowdock
method

add_setup_hook

Importance_2
v1_9_3_125 - Show latest stable - 0 notes - Class: TestCase
add_setup_hook(arg=nil, &block) public

Adds a block of code that will be executed before every TestCase is run. Equivalent to setup, but usable multiple times and without re-opening any classes.

All of the setup hooks will run in order after the setup method, if one is defined.

The argument can be any object that responds to #call or a block. That means that this call,

MiniTest::TestCase.add_setup_hook { puts "foo" }

… is equivalent to:

module MyTestSetup
  def call
    puts "foo"
  end
end

MiniTest::TestCase.add_setup_hook MyTestSetup

The blocks passed to add_setup_hook take an optional parameter that will be the TestCase instance that is executing the block.

Show source
Register or log in to add new notes.