Class: RSpock::AST::Parser::ThenBlock
- Inherits:
-
Block
- Object
- Block
- RSpock::AST::Parser::ThenBlock
show all
- Defined in:
- lib/rspock/ast/parser/then_block.rb
Instance Attribute Summary
Attributes inherited from Block
#node, #type
Instance Method Summary
collapse
Methods inherited from Block
#<<, #can_start?, #children, #range, #succession_error_msg, #valid_successor?
Constructor Details
#initialize(node) ⇒ ThenBlock
Returns a new instance of ThenBlock.
10
11
12
|
# File 'lib/rspock/ast/parser/then_block.rb', line 10
def initialize(node)
super(:Then, node)
end
|
Instance Method Details
#can_end? ⇒ Boolean
14
15
16
|
# File 'lib/rspock/ast/parser/then_block.rb', line 14
def can_end?
true
end
|
#successors ⇒ Object
18
19
20
|
# File 'lib/rspock/ast/parser/then_block.rb', line 18
def successors
@successors ||= [:Cleanup, :Where].freeze
end
|
#to_rspock_node ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rspock/ast/parser/then_block.rb', line 22
def to_rspock_node
interaction_parser = InteractionParser.new
statement_parser = StatementParser.new
spock_children = @children.map do |child|
parsed = interaction_parser.parse(child)
next parsed unless parsed.equal?(child)
statement_parser.parse(child)
end
raises_count = spock_children.count { |c| c.type == :rspock_raises }
if raises_count > 1
raise BlockError, "Then block @ #{range} may contain at most one raises() condition"
end
s(:rspock_then, *spock_children)
end
|