Sha256: 444a499e624ed6221b16dea00d0027d14ea9856627924fb28958c4bc065ffa40

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require 'clio/facets/string'
require 'clio/ansicode'

module Quarry

  # = Reporter
  #
  # Serves as the base class for all other specification 
  # output formats.
  # 
  class Reporter
    ANSICode = Clio::ANSICode

    attr :steps
    attr :pass
    attr :fail
    attr :error

    def initialize
      @specs = 0
      @steps = 0
      @pass  = []
      @fail  = []
      @error = []
    end

    # Before running any specifications.
    def report_intro
    end

    # Beginning of a specification.
    def report_start(spec)
      @specs += 1
    end

    # Report a header.
    def report_header(step)
    end

    # Report a comment.
    def report_comment(step)
    end

    # Er... what was this for?
    #def report_mode(step)
    #  report_literal(step)
    #end

    # Before running a step.
    def report_step(step)
      @steps += 1
    end

    # Report step passed.
    def report_pass(step)
      @pass << step
    end

    # Report step failed.
    def report_fail(step, assertion)
      @fail << [step, assertion]
    end

    # Report step raised an error.
    def report_error(step, exception)
      raise exception if $DEBUG
      @error << [step, exception]
    end

    # Since regular macro step does not pass or fail,
    # this method is used instead.
    #
    # TODO: Rename to #report_nominal (?)
    def report_macro(step)
    end

    # After running a step.
    def report_step_end(step)
    end

    # End of a specification.
    def report_end(spec)
    end

    # After running all specifications.
    def report_summary
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quarry-0.5.2 lib/quarry/reporter.rb