Module: Minitest::Sugar
- Defined in:
- lib/minitest/sugar.rb,
lib/minitest/sugar/version.rb
Constant Summary collapse
- VERSION =
"2.0.0"
Instance Method Summary collapse
-
#test(name, &block) ⇒ Object
Public: Helper to define a test method using a String.
Instance Method Details
#test(name, &block) ⇒ Object
Public: Helper to define a test method using a String.
Examples
require "minitest/autorun"
require "minitest/sugar"
class TruthTest < Minitest::Test
test "assert the truth" do
assert true
end
end
16 17 18 19 20 21 22 23 24 |
# File 'lib/minitest/sugar.rb', line 16 def test(name, &block) test_name = sprintf("test_%s", name.gsub(/\s+/, "_")) if (instance_method(test_name) rescue false) raise "#{ test_name } is already defined in #{ self }" end define_method(test_name, &block) end |