Class: Transpec::Syntax::Receive
- Inherits:
-
Transpec::Syntax
- Object
- Transpec::Syntax
- Transpec::Syntax::Receive
- Includes:
- Mixin::MessagingHost, Mixin::OwnedMatcher, Mixin::Send
- Defined in:
- lib/transpec/syntax/receive.rb
Defined Under Namespace
Classes: ReceiveAnyInstanceBlockRecord, ReceiveUselessAndReturnRecord
Instance Attribute Summary collapse
-
#expectation ⇒ Object
readonly
Returns the value of attribute expectation.
Attributes inherited from Transpec::Syntax
#node, #report, #runtime_data, #source_rewriter
Class Method Summary collapse
Instance Method Summary collapse
- #add_receiver_arg_to_any_instance_implementation_block! ⇒ Object
- #any_instance? ⇒ Boolean
- #any_instance_block_node ⇒ Object
- #remove_useless_and_return! ⇒ Object
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::OwnedMatcher
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
conversion_target_node?, #expression_range, #initialize, #parent_node, snake_case_name, standalone?, #static_context_inspector, target_node?
Methods included from Collection
#all_syntaxes, #inherited, #require_all, #standalone_syntaxes
Methods included from DynamicAnalysis
#register_request_for_dynamic_analysis
Instance Attribute Details
#expectation ⇒ Object (readonly)
Returns the value of attribute expectation.
13 14 15 |
# File 'lib/transpec/syntax/receive.rb', line 13 def expectation @expectation end |
Class Method Details
.target_method?(receiver_node, method_name) ⇒ Boolean
15 16 17 |
# File 'lib/transpec/syntax/receive.rb', line 15 def self.target_method?(receiver_node, method_name) receiver_node.nil? && method_name == :receive end |
Instance Method Details
#add_receiver_arg_to_any_instance_implementation_block! ⇒ Object
25 26 27 28 29 |
# File 'lib/transpec/syntax/receive.rb', line 25 def add_receiver_arg_to_any_instance_implementation_block! added = super return unless added @report.records << ReceiveAnyInstanceBlockRecord.new(self) end |
#any_instance? ⇒ Boolean
31 32 33 |
# File 'lib/transpec/syntax/receive.rb', line 31 def any_instance? @expectation.any_instance? end |
#any_instance_block_node ⇒ Object
35 36 37 38 |
# File 'lib/transpec/syntax/receive.rb', line 35 def any_instance_block_node return unless any_instance? super || @expectation.block_node end |
#remove_useless_and_return! ⇒ Object
19 20 21 22 23 |
# File 'lib/transpec/syntax/receive.rb', line 19 def remove_useless_and_return! removed = super return unless removed @report.records << ReceiveUselessAndReturnRecord.new(self) end |