Skip to content

Commit

Permalink
Add super note for hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Oct 29, 2020
1 parent 06a3d95 commit a6cd680
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,47 @@ _ { raise_exception }.must_raise TypeError

Check the http://docs.seattlerb.org/minitest/Minitest/Expectations.html[Minitest::Expectations doc] for more information about its usage.

=== Hooks [[hooks]]

If using a module containing `setup` or `teardown` methods, be sure to call `super` in the test class `setup` or
`teardown`.

[source,ruby]
----
# bad
module MyHelper
def setup
stub_something
end
end
class TestMeme < Minitest::Test
include MyHelper
def setup
do_something
end
end
# good
module MyHelper
def setup
stub_something
end
end
class TestMeme < Minitest::Test
include MyHelper
def setup
do_something
super
end
end
----

# good

== Related Guides

* https://rubystyle.guide[Ruby Style Guide]
Expand Down

0 comments on commit a6cd680

Please sign in to comment.