class Oktest::Context

Attributes

__node[RW]

Public Class Methods

after(&block) click to toggle source
# File lib/oktest.rb, line 865
def self.after(&block)
  #; [!ngkvz] registers 'after' hook block.
  @__node.register_hook_block(:after, &block)
  self
end
after_all(&block) click to toggle source
# File lib/oktest.rb, line 877
def self.after_all(&block)
  #; [!0w5ik] registers 'after_all' hook block.
  @__node.register_hook_block(:after_all, &block)
  self
end
before(&block) click to toggle source
# File lib/oktest.rb, line 859
def self.before(&block)
  #; [!275zr] registers 'before' hook block.
  @__node.register_hook_block(:before, &block)
  self
end
before_all(&block) click to toggle source
# File lib/oktest.rb, line 871
def self.before_all(&block)
  #; [!8v1y4] registers 'before_all' hook block.
  @__node.register_hook_block(:before_all, &block)
  self
end
case_else(desc=nil, tag: nil, &block) click to toggle source
# File lib/oktest.rb, line 821
def self.case_else(desc=nil, tag: nil, &block)
  #; [!hs1to] 1st parameter is optional.
  desc = desc ? "Else #{desc}" : "Else"
  #; [!oww4b] returns topic object.
  #; [!j5gnp] target is a description which is 'Else'.
  return __case_when(desc, tag, &block)
end
case_when(desc, tag: nil, &block) click to toggle source
# File lib/oktest.rb, line 815
def self.case_when(desc, tag: nil, &block)
  #; [!g3cvh] returns topic object.
  #; [!ofw1i] target is a description starting with 'When '.
  return __case_when("When #{desc}", tag, &block)
end
fixture(name, &block) click to toggle source
# File lib/oktest.rb, line 851
def self.fixture(name, &block)
  #; [!8wfrq] registers fixture factory block.
  #; [!y3ks3] retrieves block parameter names.
  location = caller(1).first  # caller() makes performance slower, but necessary.
  @__node.register_fixture_block(name, location, &block)
  self
end
spec(desc, tag: nil, &block) click to toggle source
# File lib/oktest.rb, line 835
def self.spec(desc, tag: nil, &block)
  node = @__node
  node.is_a?(Node)  or raise "internal error: node=#{node.inspect}"  # for debug
  #; [!ala78] provides raising TodoException block if block not given.
  block ||= proc { raise TodoException, "not implemented yet" }
  #; [!x48db] keeps called location only when block has parameters.
  if block.parameters.empty?
    location = nil
  else
    location = caller(1).first  # caller() makes performance slower, but necessary.
  end
  #; [!c8c8o] creates new spec object.
  spec = SpecLeaf.new(node, desc, tag: tag, location: location, &block)
  return spec
end
topic(target, tag: nil, &block) click to toggle source
# File lib/oktest.rb, line 807
def self.topic(target, tag: nil, &block)
  #; [!0gfvq] creates new topic node.
  node = @__node
  topic = TopicNode.new(node, target, tag: tag)
  topic.run_block_in_context_class(&block)
  return topic
end