Module: Minitest::Candy::Callbacks
- Included in:
- Test
- Defined in:
- lib/minitest/candy/callbacks.rb
Instance Method Summary collapse
-
#setup(&block) ⇒ Object
Public: Helper to define a
setupmethod. -
#teardown(&block) ⇒ Object
Public: Helper to define a
teardownmethod.
Instance Method Details
#setup(&block) ⇒ Object
Public: Helper to define a setup method.
Examples
require "minitest/autorun"
require "minitest/candy"
class TruthTest < Minitest::Test
setup do
@truth = true
end
test "assert the truth" do
assert @truth
end
end
21 22 23 24 25 26 27 |
# File 'lib/minitest/candy/callbacks.rb', line 21 def setup(&block) define_method(:setup) do super() instance_exec(&block) end end |
#teardown(&block) ⇒ Object
Public: Helper to define a teardown method.
Examples
require "minitest/autorun"
require "minitest/candy"
class TruthTest < Minitest::Test
setup do
@truth = true
end
teardown do
@truth = nil
end
test "assert the truth" do
assert @truth
end
end
50 51 52 53 54 55 56 |
# File 'lib/minitest/candy/callbacks.rb', line 50 def teardown(&block) define_method(:teardown) do instance_exec(&block) super() end end |