Class: RSpock::AST::TestMethodDefTransformation

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

Overview

Appends the data row's index and source line to a Where-driven test's name. The values arrive through internal block parameters on the row iterator (see TestMethodTransformation#build_where_args) and surface in the test NAME only: the name is what makes identical data rows unique and what the -n selector matches to isolate a row. They are deliberately not exposed as test-scope variables.

Constant Summary collapse

ROW_INDEX_ARG =
:__rspock_row_index__
ROW_LINE_ARG =
:__rspock_row_line__
ROW_INDEX_AST =
s(:begin, s(:lvar, ROW_INDEX_ARG))
ROW_LINE_AST =
s(:begin, s(:lvar, ROW_LINE_ARG))
LINE_NUMBER_STR_AST =
s(:str, " line ")

Instance Method Summary collapse

Instance Method Details

#on_dstr(node) ⇒ Object



30
31
32
# File 'lib/rspock/ast/test_method_def_transformation.rb', line 30

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

#on_str(node) ⇒ Object



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

def on_str(node)
  merged = s(:str, "#{node.children[0]} ")
  node.updated(:dstr, [merged, ROW_INDEX_AST, LINE_NUMBER_STR_AST, ROW_LINE_AST])
end

#run(node) ⇒ Object



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

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

  super
end