class MiniTest::Spec

def self.after type = :each, &block

def self.after type = :each, &block
  raise "unsupported after type: #{type}" unless type == :each
  define_inheritable_method :teardown, &block
end

def self.before type = :each, &block

def self.before type = :each, &block
  raise "unsupported before type: #{type}" unless type == :each
  define_inheritable_method :setup, &block
end

def self.current # :nodoc:

:nodoc:
def self.current # :nodoc:
  @@current_spec
end

def self.define_inheritable_method name, &block # :nodoc:

:nodoc:
def self.define_inheritable_method name, &block # :nodoc:
  super_method = self.superclass.instance_method name
  define_method name do
    super_method.bind(self).call if super_method # regular super() warns
    instance_eval(&block)
  end
end

def self.describe_stack # :nodoc:

:nodoc:
def self.describe_stack # :nodoc:
  @@describe_stack
end

def self.it desc, &block

def self.it desc, &block
  block ||= proc { skip "(no tests defined)" }
  @specs ||= 0
  @specs += 1
  name = "test_%04d_%s" % [ @specs, desc.gsub(/\W+/, '_').downcase ]
  define_method name, &block
  classes(MiniTest::Spec).each do |mod|
    mod.send :undef_method, name if mod.respond_to? name
  end
end

def self.nuke_test_methods! # :nodoc:

:nodoc:
def self.nuke_test_methods! # :nodoc:
  self.public_instance_methods.grep(/^test_/).each do |name|
    self.send :undef_method, name
  end
end

def initialize name # :nodoc:

:nodoc:
def initialize name # :nodoc:
  super
  @@current_spec = self
end