Module: Transpec::Syntax::Mixin::AnyInstance

Included in:
Transpec::Syntax::MethodStub, ShouldReceive
Defined in:
lib/transpec/syntax/mixin/any_instance.rb

Instance Method Summary collapse

Instance Method Details

#any_instance?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/transpec/syntax/mixin/any_instance.rb', line 7

def any_instance?
  !class_node_of_any_instance.nil?
end

#class_node_of_any_instanceObject



11
12
13
14
15
16
17
18
# File 'lib/transpec/syntax/mixin/any_instance.rb', line 11

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