Sha256: ef069abef1341cd81a4340397b633016aa4e996af92860960d4dae0f09d4a246

Contents?: true

Size: 820 Bytes

Versions: 3

Compression:

Stored size: 820 Bytes

Contents

module Rgot
  class T < Common
    def initialize(test_module, name, opts={})
      super()
      @module = test_module
      @name = name
      @opts = opts
      @module.extend @module
    end

    def run
      begin
        catch(:skip) { call }
        finish!
      rescue => e
        fail!
        report
        raise e
      end
    end

    def report
      duration = Rgot.now - @start
      template = "--- %s: %s (%.5fs)\n%s"
      if failed?
        printf template, "FAIL", @name, duration, @output
      elsif @opts[:verbose]
        if skipped?
          printf template, "SKIP", @name, duration, @output
        else
          printf template, "PASS", @name, duration, @output
        end
      end
    end

    def call
      @module.instance_method(@name).bind(@module).call(self)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rgot-0.0.5 lib/rgot/t.rb
rgot-0.0.4 lib/rgot/t.rb
rgot-0.0.3 lib/rgot/t.rb