Class: Solargraph::Rspec::SpecWalker::FakeLetMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/rspec/spec_walker/fake_let_method.rb

Constant Summary collapse

MATCH_DO_END =
/.*? do(.*)end/m
MATCH_CURLY =
/{(.*)}/m

Class Method Summary collapse

Class Method Details

.transform_block(block_ast, method_name = nil) ⇒ ::Parser::AST::Node?

Transforms let block to method ast node

Parameters:

  • block_ast (::Parser::AST::Node)
  • method_name (String, nil) (defaults to: nil)

Returns:

  • (::Parser::AST::Node, nil)


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/solargraph/rspec/spec_walker/fake_let_method.rb', line 15

def transform_block(block_ast, method_name = nil)
  method_name ||= NodeTypes.let_method_name(block_ast)

  ::Parser::AST::Node.new( # transform let block to a method ast node
    :def,
    [
      method_name.to_sym,
      ::Parser::AST::Node.new(:args, []),
      block_ast.children[2]
    ]
  )
end