Class: RSpock::AST::ComparisonToAssertionTransformation

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

Instance Method Summary collapse

Constructor Details

#initialize(*ignored_method_call_symbols) ⇒ ComparisonToAssertionTransformation

Returns a new instance of ComparisonToAssertionTransformation.



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

def initialize(*ignored_method_call_symbols)
  @method_call_transformation = RSpock::AST::MethodCallToLVarTransformation.new(*ignored_method_call_symbols)
end

Instance Method Details

#on_send(node) ⇒ Object



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

def on_send(node)
  if node.children.count == 3 && node.children[1] == :== && ignored_method_call_node?(node)
    transform_to_assert_equal(node)
  elsif node.children.count == 3 && node.children[1] == :!= && ignored_method_call_node?(node)
    transform_to_refute_equal(node)
  else
    node.updated(nil, process_all(node))
  end
end