Module: Transpec::Syntax::AbleToTargetAnyInstance

Includes:
SendNodeSyntax
Included in:
MethodStub, ShouldReceive
Defined in:
lib/transpec/syntax/able_to_target_any_instance.rb

Instance Method Summary collapse

Methods included from SendNodeSyntax

#arg_node, #arg_range, #method_name, #parentheses_range, #receiver_node, #receiver_range, #selector_range

Instance Method Details

#any_instance?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/transpec/syntax/able_to_target_any_instance.rb', line 10

def any_instance?
  !class_node_of_any_instance.nil?
end

#class_node_of_any_instanceObject



14
15
16
17
18
19
20
21
# File 'lib/transpec/syntax/able_to_target_any_instance.rb', line 14

def class_node_of_any_instance
  return nil unless subject_node.type == :send
  return nil unless subject_node.children.count == 2
  receiver_node, method_name = *subject_node
  return nil unless method_name == :any_instance
  return nil unless receiver_node.type == :const
  receiver_node
end