Class: RSpock::AST::TestMethodDefTransformation

Inherits:
ASTTransform::AbstractTransformation
  • Object
show all
Defined in:
lib/rspock/ast/test_method_def_transformation.rb

Constant Summary collapse

TEST_INDEX_AST =
s(:begin,
s(:lvar, :_test_index_))
LINE_NUMBER_AST =
s(:begin,
s(:lvar, :_line_number_))
SPACE_STR_AST =
s(:str, " ")
LINE_NUMBER_STR_AST =
s(:str, " line ")

Instance Method Summary collapse

Instance Method Details

#on_dstr(node) ⇒ Object



28
29
30
# File 'lib/rspock/ast/test_method_def_transformation.rb', line 28

def on_dstr(node)
  TestMethodDstrTransformation.new.run(node)
end

#on_str(node) ⇒ Object



24
25
26
# File 'lib/rspock/ast/test_method_def_transformation.rb', line 24

def on_str(node)
  node.updated(:dstr, [node, SPACE_STR_AST, TEST_INDEX_AST, LINE_NUMBER_STR_AST, LINE_NUMBER_AST])
end

#run(node) ⇒ Object



18
19
20
21
22
# File 'lib/rspock/ast/test_method_def_transformation.rb', line 18

def run(node)
  return node unless node.type == :send && node.children[0].nil? && node.children[1] == :test

  super
end