Sha256: 8334d206587acffc98617cc91a61bf63e79fae18e1d10df55dda513ae207d618

Contents?: true

Size: 1.39 KB

Versions: 12

Compression:

Stored size: 1.39 KB

Contents

class SpecReporter < BaseReporter

  def initialize()
    super()
    self.indents = 0
    self.log_buffer = []
  end

  defm write(msg)
    line = "#{self.indent_to_str()}#{msg}"
    self.writer.writeln(line)
  end

  defm on_start(stats)
  end

  defm on_context_start(context, stats)
    self.write("#{context}")
    self.indent(1)
  end

  defm on_context_end(context, stats)
    self.unindent(1)
  end

  defm on_spec_pass(meta, stats)
    duration_msg = self.get_duration_msg(meta)
    self.write("#{self.get_tick()} #{meta.get_sentence()} #{duration_msg}")
    self.indent(2)
    self.flush_log_buffer()
    self.unindent(2)
  end

  defm on_spec_failure(meta, err, stats)
    self.write("#{self.get_cross()} #{self.to_red(meta.get_sentence())}")
    self.indent(2)
    self.write(self.to_red(err.get_message()))

    self.indent(1)
    self.print_stacktrace(err)
    self.unindent(1)

    self.flush_log_buffer()
    self.unindent(2)
  end

  defm on_spec_error(meta, err, stats)
    self.on_spec_failure(meta, err, stats)
  end

  defm indent_to_str()
    return repeat("  ", self.indents)
  end

  defm indent(size)
    self.indents += size
  end

  defm unindent(size)
    self.indents -= size
  end

  defm write_epilogue_separator()
    self.writer.writeln('')
    super()
  end

  defm write_log_line(line)
    self.write("log: #{line}")
  end
  
  defm write_stacktrace_line(line)
    self.write(line)
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
speckle-0.1.26 lib/reporters/spec_reporter.riml
speckle-0.1.25 lib/reporters/spec_reporter.riml
speckle-0.1.24 lib/reporters/spec_reporter.riml
speckle-0.1.23 lib/reporters/spec_reporter.riml
speckle-0.1.22 lib/reporters/spec_reporter.riml
speckle-0.1.21 lib/reporters/spec_reporter.riml
speckle-0.1.20 lib/reporters/spec_reporter.riml
speckle-0.1.19 lib/reporters/spec_reporter.riml
speckle-0.1.18 lib/reporters/spec_reporter.riml
speckle-0.1.17 lib/reporters/spec_reporter.riml
speckle-0.1.16 lib/reporters/spec_reporter.riml
speckle-0.1.15 lib/reporters/spec_reporter.riml