Class: Transpec::Syntax::ShouldReceive

Inherits:
Transpec::Syntax show all
Includes:
AbleToAllowNoMessage, AbleToTargetAnyInstance, Expectizable
Defined in:
lib/transpec/syntax/should_receive.rb

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#ancestor_nodes, #node, #report, #source_rewriter

Instance Method Summary collapse

Methods included from Expectizable

#wrap_subject_in_expect!

Methods included from SendNodeSyntax

#arg_node, #arg_nodes, #arg_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 AbleToAllowNoMessage

#allow_no_message?, #remove_allowance_for_no_message!

Methods included from AbleToTargetAnyInstance

#any_instance?, #class_node_of_any_instance

Methods inherited from Transpec::Syntax

all, #context, #expression_range, inherited, #initialize, #parent_node, snake_case_name, target_node?

Constructor Details

This class inherits a constructor from Transpec::Syntax

Instance Method Details

#allowize_useless_expectation!(negative_form = 'not_to') ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/transpec/syntax/should_receive.rb', line 24

def allowize_useless_expectation!(negative_form = 'not_to')
  return unless useless_expectation?

  convert_to_syntax!('allow', negative_form)
  remove_allowance_for_no_message!

  register_record(:allow, negative_form)
end

#expectize!(negative_form = 'not_to') ⇒ Object



19
20
21
22
# File 'lib/transpec/syntax/should_receive.rb', line 19

def expectize!(negative_form = 'not_to')
  convert_to_syntax!('expect', negative_form)
  register_record(:expect, negative_form)
end

#positive?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/transpec/syntax/should_receive.rb', line 15

def positive?
  method_name == :should_receive
end

#stubize_useless_expectation!Object



33
34
35
36
37
38
39
40
# File 'lib/transpec/syntax/should_receive.rb', line 33

def stubize_useless_expectation!
  return unless useless_expectation?

  replace(selector_range, 'stub')
  remove_allowance_for_no_message!

  register_record(:stub)
end