Permalink
Browse files

+ Added FAQ entry for extending via modules. (phiggins)

[git-p4: depot-paths = "//src/minitest/dev/": change = 8517]
  • Loading branch information...
1 parent 2fa9185 commit c81fd2f31224298172c3ece158e2480563b8eb16 @zenspider zenspider committed May 9, 2013
Showing with 24 additions and 0 deletions.
  1. +24 −0 README.txt
View
@@ -302,6 +302,30 @@ or you can extend the Worker class (within the test file!), like:
include ::MiniTest::Expectations
end
+=== How to share code across test classes?
+
+Use a module. That's exactly what they're for:
+
+ module UsefulStuff
+ def useful_method
+ # ...
+ end
+ end
+
+ describe Blah do
+ include UsefulStuff
+
+ def test_whatever
+ # useful_method available here
+ end
+ end
+
+Remember, `describe` simply creates test classes. It's just ruby at
+the end of the day and all your normal Good Ruby Rules (tm) apply. If
+you want to extend your test using setup/teardown via a module, just
+make sure you ALWAYS call super. before/after automatically call super
+for you, so make sure you don't do it twice.
+
== Known Extensions:
capybara_minitest_spec :: Bridge between Capybara RSpec matchers and MiniTest::Spec expectations (e.g. page.must_have_content("Title")).

0 comments on commit c81fd2f

Please sign in to comment.