Sha256: ba6170be68957e1cb8ac65c879d9fd20fbe87ca440f698ff6c396c0775b7ffc0

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

module Minitest
  module Sugar
    # Allow to create tests in a more human readable form.
    #
    #  class TruthTest < Minitest::Test
    #    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

1 entries across 1 versions & 1 rubygems

Version Path
minitest-sugar-1.0.0 lib/minitest/sugar.rb