Skip to content

Commit

Permalink
+ Added FAQ entry for extending via modules. (phiggins)
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/minitest/dev/": change = 8517]
  • Loading branch information
zenspider committed May 9, 2013
1 parent 2fa9185 commit c81fd2f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.txt
Expand Up @@ -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")).
Expand Down

0 comments on commit c81fd2f

Please sign in to comment.