class Lemon::TestProc

Test procedure.

Attributes

context[R]

The parent case to which this test belongs.

label[R]

Description of test.

procedure[R]

Test procedure, in which test assertions should be made.

setup[R]

Setup and teardown procedures.

skip[RW]
tested[RW]

Has this test been executed?

Public Class Methods

new(settings={}, &procedure) click to toggle source

New test procedure.

# File lib/lemon/test_proc.rb, line 9
def initialize(settings={}, &procedure)
  @context = settings[:context]
  @setup   = settings[:setup]
  @label   = settings[:label]
  @skip    = settings[:skip]
  @tags    = settings[:tags]

  @procedure = procedure

  @tested    = false
end

Public Instance Methods

arguments() click to toggle source

TODO: handle parameterized tests

# File lib/lemon/test_proc.rb, line 105
def arguments
  []
end
call() click to toggle source

Run the test.

# File lib/lemon/test_proc.rb, line 128
def call
  context.run(self) do
    setup.run_setup(scope)    if setup
    scope.instance_exec(*arguments, &procedure)
    setup.run_teardown(scope) if setup
  end
end
match?(match) click to toggle source
# File lib/lemon/test_proc.rb, line 121
def match?(match)    
  match == target || match === description
end
name()
Alias for: to_s
scope() click to toggle source
# File lib/lemon/test_proc.rb, line 139
def scope
  context.scope
end
skip?() click to toggle source

Don't run test?

# File lib/lemon/test_proc.rb, line 51
def skip?
  @skip
end
tags() click to toggle source
# File lib/lemon/test_proc.rb, line 58
def tags
  @tags
end
target() click to toggle source

Target method of context.

# File lib/lemon/test_proc.rb, line 41
def target
  context.target
end
to_proc() click to toggle source
# File lib/lemon/test_proc.rb, line 112
def to_proc
  lambda do
    call
  end
end
to_s() click to toggle source

Test label.

# File lib/lemon/test_proc.rb, line 68
def to_s
  label.to_s
end
Also aliased as: name
topic() click to toggle source

Ruby Test looks for topic as the description of test setup.

@todo This may be deprecated in future RubyTest.

# File lib/lemon/test_proc.rb, line 79
def topic
  setup.to_s
end