Class: RSpock::AST::StartBlock

Inherits:
Block
  • Object
show all
Defined in:
lib/rspock/ast/start_block.rb

Constant Summary collapse

SUCCESSORS_WITHOUT_CHILDREN =
[:Given, :When, :Expect].freeze
SUCCESSORS_WITH_CHILDREN =
[:End].freeze

Instance Attribute Summary

Attributes inherited from Block

#node, #type

Instance Method Summary collapse

Methods inherited from Block

#<<, #children, #node_container=, #node_container?, #range, #unshift, #valid_successor?

Constructor Details

#initialize(node) ⇒ StartBlock

Returns a new instance of StartBlock.



7
8
9
10
# File 'lib/rspock/ast/start_block.rb', line 7

def initialize(node)
  super(:Start, node)
  @node_container = false
end

Instance Method Details

#succession_error_msgObject



20
21
22
# File 'lib/rspock/ast/start_block.rb', line 20

def succession_error_msg
  "Test method @ #{range} must start with one of these Blocks: #{successors}"
end

#successorsObject



12
13
14
15
16
17
18
# File 'lib/rspock/ast/start_block.rb', line 12

def successors
  if @children.empty?
    SUCCESSORS_WITHOUT_CHILDREN
  else
    SUCCESSORS_WITH_CHILDREN
  end
end