Skip to content

Instantly share code, notes, and snippets.

@revans
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revans/9096614 to your computer and use it in GitHub Desktop.
Save revans/9096614 to your computer and use it in GitHub Desktop.
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"
#
@revans
Copy link
Author

revans commented Feb 19, 2014

Just a quick and dirty example of extending Minitest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment