Last active
August 29, 2015 13:56
-
-
Save revans/9096614 to your computer and use it in GitHub Desktop.
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
module TestMethodAlternatives | |
def testing(description, &block) | |
formatted_desc = description.gsub(/\s+/, '_').gsub(/\W+/, '') | |
define_method("test_#{formatted_desc}") do | |
if block_given? | |
instance_eval(&block) | |
else | |
instance_eval do | |
skip("test_#{formatted_desc}") | |
end | |
end | |
end | |
end | |
end | |
class Minitest::Test | |
extend TestMethodAlternatives | |
end | |
# e.g. | |
# | |
# testing "zero should equal zero" do | |
# assert 0.zero? | |
# end | |
# | |
# | |
# testing "a placeholder test case" | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a quick and dirty example of extending Minitest.