Sha256: acca576f8a69836b7eb643bbad4784c4c0503ed0fd32195dc227f59d2165fea8

Contents?: true

Size: 679 Bytes

Versions: 2

Compression:

Stored size: 679 Bytes

Contents

module MiniTest
  module Sugar
    # Allow to create tests in a more human readable form.
    #
    #  class TruthTest < MiniTest::Unit::TestCase
    #    extend MiniTest::Sugar
    #
    #    test 'assert the truth' do
    #      assert true
    #    end
    #  end
    def test name, &block
      test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
      defined = instance_method(test_name) rescue false
      raise "#{test_name} is already defined in #{self}" if defined

      if block_given?
        define_method test_name, &block
      else
        define_method test_name do
          flunk 'No implementation provided for #{name}'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
minitest-sugar-0.0.4 lib/minitest/sugar.rb
minitest-sugar-0.0.3 lib/minitest-sugar.rb