From a6cd680b2f95b6611f942eef876d132b587453bb Mon Sep 17 00:00:00 2001 From: Andy Waite Date: Wed, 28 Oct 2020 22:54:07 -0400 Subject: [PATCH] Add super note for hooks --- README.adoc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.adoc b/README.adoc index b3b558c..cd357f9 100644 --- a/README.adoc +++ b/README.adoc @@ -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]