Module: Transpec::Syntax::AnyInstanceable

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

Instance Method Summary collapse

Methods included from SendNodeSyntax

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

Instance Method Details

#any_instance?Boolean



10
11
12
# File 'lib/transpec/syntax/any_instanceable.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/any_instanceable.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