Module: Transpec::Syntax::Mixin::ExpectBase
- Extended by:
- ActiveSupport::Concern
- Includes:
- MatcherOwner, Send
- Included in:
- Allow, Expect
- Defined in:
- lib/transpec/syntax/mixin/expect_base.rb
Instance Method Summary
collapse
Methods included from 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
#conversion_target?
#dependent_syntaxes
Instance Method Details
#current_syntax_type ⇒ Object
24
25
26
|
# File 'lib/transpec/syntax/mixin/expect_base.rb', line 24
def current_syntax_type
:expect
end
|
#dynamic_analysis_target? ⇒ Boolean
20
21
22
|
# File 'lib/transpec/syntax/mixin/expect_base.rb', line 20
def dynamic_analysis_target?
super && receiver_node.nil? && matcher_node
end
|
#matcher_node ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/transpec/syntax/mixin/expect_base.rb', line 54
def matcher_node
return nil unless to_node
to_arg_node = to_node.children[2]
return nil unless to_arg_node
Util.each_forward_chained_node(to_arg_node, :include_origin)
.select(&:send_type?).to_a.last
end
|
#method_name_for_instance ⇒ Object
28
29
30
|
# File 'lib/transpec/syntax/mixin/expect_base.rb', line 28
def method_name_for_instance
fail NotImplementedError
end
|
#positive? ⇒ Boolean
32
33
34
35
36
|
# File 'lib/transpec/syntax/mixin/expect_base.rb', line 32
def positive?
to_method_name = to_node.children[1]
[:to, :should].include?(to_method_name)
end
|
#subject_node ⇒ Object
38
39
40
|
# File 'lib/transpec/syntax/mixin/expect_base.rb', line 38
def subject_node
arg_node || parent_node
end
|
#subject_range ⇒ Object
66
67
68
|
# File 'lib/transpec/syntax/mixin/expect_base.rb', line 66
def subject_range
subject_node.loc.expression
end
|
#to_node ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/transpec/syntax/mixin/expect_base.rb', line 42
def to_node
return nil unless parent_node
if parent_node.block_type? && parent_node.children.first.equal?(node)
parent_node.parent
elsif parent_node.send_type? && parent_node.children.first.equal?(node)
parent_node
else
nil
end
end
|