Sha256: b0e8243ace4cbc428b70b4bbf23e8c9053cc5ee0806fb71d26cef7d7a2e9dc21

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 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 false
    #    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-0.0.2 lib/minitest-sugar.rb