Module: Minitest::Tags::ClassMethods

Defined in:
lib/minitest/tags.rb

Instance Method Summary collapse

Instance Method Details

#it(desc, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/minitest/tags.rb', line 11

def it desc, &block
tags = desc.match(/\(([\s\S]+)\)/)[1].split(",").map(&:strip) if desc.match(/\(([\s\S]+)\)/)
tags = tags || [] 
tag = ENV["TAG"]
block =  proc { skip "(only the desc including tag #{tag} available)" } unless tags.include?(tag)
block ||= proc { skip "(no tests defined)" }

@specs ||= 0
@specs += 1

name = "test_%04d_%s" % [ @specs, desc.gsub(/\W+/, '_').downcase ]

define_method name, &block

self.children.each do |mod|
  mod.send :undef_method, name if mod.public_method_defined? name
end 
end