class Shindo::Tests

def assert(type, expectation, description, &block)

def assert(type, expectation, description, &block)
  return if Thread.main[:exit] || Thread.current[:reload]
  description = [@description, description].compact.join(' ')
  if block_given?
    begin
      for before in @befores.flatten.compact
        before.call
      end
      value, success = case type
      when :raises
        raises?(expectation, &block)
      when :returns
        returns?(expectation, &block)
      end
      for after in @afters.flatten.compact
        after.call
      end
    rescue => error
      success = false
      value = error
    end
    if success
      display_success(description)
    else
      display_failure(description)
      case value
      when Exception, Interrupt
        display_error(value)
      else
        @message ||= [
          "expected => #{expectation.inspect}",
          "returned => #{value.inspect}"
        ]
        Thread.current[:formatador].indent do
          Thread.current[:formatador].display_lines([*@message].map {|message| "[red]#{message}[/]"})
        end
        @message = nil
      end
      if Thread.current[:interactive] && STDOUT.tty?
        prompt(description, &block)
      end
    end
  else
    display_pending(description)
  end
  success
end