Class: Transpec::Syntax::RaiseError
- Inherits:
-
Transpec::Syntax
- Object
- Transpec::Syntax
- Transpec::Syntax::RaiseError
- Includes:
- Mixin::Send
- Defined in:
- lib/transpec/syntax/raise_error.rb
Instance Attribute Summary
Attributes inherited from Transpec::Syntax
#ancestor_nodes, #node, #report, #runtime_data, #source_rewriter
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Mixin::Send
#arg_node, #arg_nodes, #arg_range, included, #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 inherited from Transpec::Syntax
all_syntaxes, #expression_range, inherited, #initialize, #parent_node, #register_request_for_dynamic_analysis, register_request_for_dynamic_analysis, snake_case_name, standalone?, standalone_syntaxes, #static_context_inspector, target_node?
Constructor Details
This class inherits a constructor from Transpec::Syntax
Class Method Details
.target_method?(receiver_node, method_name) ⇒ Boolean
11 12 13 |
# File 'lib/transpec/syntax/raise_error.rb', line 11 def self.target_method?(receiver_node, method_name) receiver_node.nil? && method_name == :raise_error end |
Instance Method Details
#positive? ⇒ Boolean
26 27 28 29 30 31 32 33 34 |
# File 'lib/transpec/syntax/raise_error.rb', line 26 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
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/transpec/syntax/raise_error.rb', line 15 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 |