Class: Transpec::Syntax::ShouldReceive
Defined Under Namespace
Classes: AllowRecord, ExpectBaseRecord, ExpectRecord, StubRecord
Constant Summary
Constants included
from Util
Util::LITERAL_TYPES, Util::WHITESPACES
Instance Method Summary
collapse
#wrap_subject_in_expect!
#any_instance?
#register_syntax_availability_analysis_request, #subject_node, #subject_range, #syntax_available?
#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
#conversion_target?
#need_to_add_receiver_arg_to_any_instance_implementation_block?
#allow_no_message?, #any_number_of_times?, #at_least_zero?, #remove_no_message_allowance!
#and_return?, #and_return_node, #and_return_with_block?, #useless_and_return?
Methods included from Util
beginning_of_line_range, block_node_taken_by_method, chainable_source, const_name, contain_here_document?, each_backward_chained_node, each_forward_chained_node, each_line_range, expand_range_to_adjacent_whitespaces, find_consecutive_whitespace_position, first_block_arg_name, here_document?, in_explicit_parentheses?, indentation_of_line, line_range, literal?, proc_literal?, range_from_arg
Instance Method Details
#add_receiver_arg_to_any_instance_implementation_block! ⇒ Object
83
84
85
|
# File 'lib/transpec/syntax/should_receive.rb', line 83
def add_receiver_arg_to_any_instance_implementation_block!
super && add_record(MonkeyPatchAnyInstanceBlockRecord)
end
|
#allow_to_receive_available? ⇒ Boolean
40
41
42
|
# File 'lib/transpec/syntax/should_receive.rb', line 40
def allow_to_receive_available?
syntax_available?(__method__)
end
|
#allowize_useless_expectation!(negative_form = 'not_to') ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/transpec/syntax/should_receive.rb', line 57
def allowize_useless_expectation!(negative_form = 'not_to')
return unless useless_expectation?
unless allow_to_receive_available?
fail ContextError.new("##{method_name}", '#allow', selector_range)
end
convert_to_syntax!('allow', negative_form)
remove_no_message_allowance!
add_record(AllowRecord, negative_form)
end
|
#dynamic_analysis_target? ⇒ Boolean
30
31
32
33
34
|
# File 'lib/transpec/syntax/should_receive.rb', line 30
def dynamic_analysis_target?
super &&
receiver_node &&
[:should_receive, :should_not_receive].include?(method_name)
end
|
#expect_to_receive_available? ⇒ Boolean
36
37
38
|
# File 'lib/transpec/syntax/should_receive.rb', line 36
def expect_to_receive_available?
syntax_available?(__method__)
end
|
#expectize!(negative_form = 'not_to') ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/transpec/syntax/should_receive.rb', line 48
def expectize!(negative_form = 'not_to')
unless expect_to_receive_available?
fail ContextError.new("##{method_name}", '#expect', selector_range)
end
convert_to_syntax!('expect', negative_form)
add_record(ExpectRecord, negative_form)
end
|
#positive? ⇒ Boolean
44
45
46
|
# File 'lib/transpec/syntax/should_receive.rb', line 44
def positive?
method_name == :should_receive
end
|
#remove_useless_and_return! ⇒ Object
79
80
81
|
# File 'lib/transpec/syntax/should_receive.rb', line 79
def remove_useless_and_return!
super && add_record(MonkeyPatchUselessAndReturnRecord)
end
|
#stubize_useless_expectation! ⇒ Object
70
71
72
73
74
75
76
77
|
# File 'lib/transpec/syntax/should_receive.rb', line 70
def stubize_useless_expectation!
return unless useless_expectation?
replace(selector_range, 'stub')
remove_no_message_allowance!
add_record(StubRecord)
end
|