Class: Transpec::Syntax::RaiseError
- Inherits:
-
Syntax
- Object
- Syntax
- Transpec::Syntax::RaiseError
show all
- Includes:
- SendNodeSyntax
- Defined in:
- lib/transpec/syntax/raise_error.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#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
Class Method Details
.target_method_names ⇒ Object
38
39
40
|
# File 'lib/transpec/syntax/raise_error.rb', line 38
def self.target_method_names
[:raise_error]
end
|
.target_receiver_node?(node) ⇒ Boolean
34
35
36
|
# File 'lib/transpec/syntax/raise_error.rb', line 34
def self.target_receiver_node?(node)
node.nil?
end
|
Instance Method Details
#positive? ⇒ Boolean
22
23
24
25
26
27
28
29
30
|
# File 'lib/transpec/syntax/raise_error.rb', line 22
def positive?
ancestor_nodes.reverse_each do |ancestor_node|
next unless ancestor_node.type == :send
expectation_method_name = ancestor_node.children[1]
return [:should, :to].include?(expectation_method_name)
end
false
end
|
#remove_error_specification_with_negative_expectation! ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/transpec/syntax/raise_error.rb', line 11
def remove_error_specification_with_negative_expectation!
return if positive?
_receiver_node, _method_name, *arg_nodes = *node
return if arg_nodes.empty?
remove(parentheses_range)
register_record
end
|