Last active
December 11, 2015 13:28
-
-
Save webmat/4607174 to your computer and use it in GitHub Desktop.
Missing Rails-style declarative helpers in your plain minitest/unit test suite? Here's something to get you started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MiniTest::Unit::TestCase | |
class << self # The def self.test way of doing it doesn't override Kernel.test but this does... | |
def test(name, &block) | |
method_name = "test_#{ name.gsub(/[\W]/, '_') }" | |
if block.nil? | |
define_method(method_name) do | |
flunk "Missing implementation for test #{name.inspect}" | |
end | |
else | |
define_method(method_name, &block) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment