Sha256: 6cebdba00961bf1e8585ea226d78b2a4a7d7e97b7bfaf1886140d1e5ce8886d6

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Lemon::Test

  #
  class Unit

    # The test case to which this unit test belongs.
    attr :testcase

    # The concern which this test helps ensure.
    attr :concern

    # A test unit +target+ is a method.
    attr :target

    # The aspect of the concern this test fulfills.
    attr :aspect

    # Test procedure, in which test assertions should be made.
    attr :procedure

    # New unit test.
    def initialize(concern, target, aspect=nil, &procedure)
      concern.assign(self)

      @concern   = concern
      @testcase  = concern.testcase

      @target    = target
      @aspect    = aspect
      @procedure = procedure
    end

    # This method has the other end of the BIG FAT HACK. See Suite#const_missing.
    def call
      Lemon.test_stack << self  # hack
      procedure.call
    ensure
      Lemon.test_stack.pop
    end

    # The suite to which this unit test belongs.
    def suite
      testcase.suite
    end

    #
    def to_s
      "#{testcase}##{target} #{aspect}"
    end

  end

end



Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lemon-0.6 lib/lemon/test/unit.rb