Sha256: fc3664bfbb7a66d880a4068368d8521f62ddac2cc95e1b268e6f5e7091fee3f9

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

require 'assert/options'

module Assert::View

  class Base
    include Assert::Options

    attr_reader :suite

    def initialize(suite, output_io)
      @suite = suite
      @out = output_io
    end

    # override this to define how a view calls the runner and renders its results
    def render(*args, &runner)
    end

    def handle_runtime_result(result)
      sym = result.to_sym
      if self.respond_to?(:options)
        io_print(self.options.send("#{sym}_abbrev"))
      end
    end

    protected

    def io_puts(msg, opts={})
      @out.puts(io_msg(msg, opts={}))
    end

    def io_print(msg, opts={})
      @out.print(io_msg(msg, opts={}))
    end

    def io_msg(msg, opts={})
      if msg.kind_of?(::Symbol) && self.respond_to?(msg)
        self.send(msg).to_s
      else
        msg.to_s
      end
    end

    def run_time(format='%.6f')
      format % @suite.run_time
    end

    def count(type)
      @suite.count(type)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
assert-0.3.0 lib/assert/view/base.rb
assert-0.2.1 lib/assert/view/base.rb
assert-0.2.0 lib/assert/view/base.rb