Class: Transpec::Syntax::Receive

Inherits:
Transpec::Syntax show all
Includes:
Mixin::MessagingHost, Mixin::OwnedMatcher, Mixin::Send
Defined in:
lib/transpec/syntax/receive.rb

Defined Under Namespace

Classes: AnyInstanceBlockRecordBuilder, UselessAndReturnRecordBuilder

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#node, #project, #report, #runtime_data, #source_rewriter

Instance Method Summary collapse

Methods included from Mixin::Send

#arg_node, #arg_nodes, #arg_range, #args_range, #method_name, #parentheses_range, #range_after_arg, #range_in_between_receiver_and_selector, #range_in_between_selector_and_arg, #receiver_node, #receiver_range, #selector_range

Methods included from Mixin::Send::TargetDetection

#conversion_target?

Methods included from Mixin::OwnedMatcher

#initialize

Methods included from Mixin::AnyInstanceBlock

#need_to_add_receiver_arg_to_any_instance_implementation_block?

Methods included from Mixin::NoMessageAllowance

#allow_no_message?, #any_number_of_times?, #at_least_zero?, #remove_no_message_allowance!

Methods included from Mixin::UselessAndReturn

#and_return?, #and_return_node, #and_return_with_block?, #useless_and_return?

Methods inherited from Transpec::Syntax

#add_record, #conversion_target?, #dependent_syntaxes, #expression_range, #initialize, #inspect, #parent_node, #rspec_version, snake_case_name, standalone?, #static_context_inspector

Methods included from Collection

#all_syntaxes, #inherited, #mixins, #require_all, #standalone_syntaxes

Methods included from DynamicAnalysis

#register_dynamic_analysis_request

Instance Method Details

#add_receiver_arg_to_any_instance_implementation_block!Object



23
24
25
26
27
# File 'lib/transpec/syntax/receive.rb', line 23

def add_receiver_arg_to_any_instance_implementation_block!
  added = super
  return unless added
  add_record(AnyInstanceBlockRecordBuilder.build(self))
end

#any_instance?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/transpec/syntax/receive.rb', line 29

def any_instance?
  expectation.any_instance?
end

#any_instance_block_nodeObject



33
34
35
36
# File 'lib/transpec/syntax/receive.rb', line 33

def any_instance_block_node
  return unless any_instance?
  super || expectation.block_node
end

#dynamic_analysis_target?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/transpec/syntax/receive.rb', line 13

def dynamic_analysis_target?
  super && receiver_node.nil? && method_name == :receive
end

#remove_useless_and_return!Object



17
18
19
20
21
# File 'lib/transpec/syntax/receive.rb', line 17

def remove_useless_and_return!
  removed = super
  return unless removed
  add_record(UselessAndReturnRecordBuilder.build(self))
end