Class: Transpec::Syntax::RaiseError

Inherits:
Transpec::Syntax show all
Includes:
Mixin::OwnedMatcher, Mixin::Send
Defined in:
lib/transpec/syntax/raise_error.rb

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#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, #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

Methods included from Mixin::OwnedMatcher

#initialize

Methods inherited from Transpec::Syntax

conversion_target_node?, #expression_range, #initialize, #parent_node, snake_case_name, standalone?, #static_context_inspector, target_node?

Methods included from Collection

#all_syntaxes, #inherited, #require_all, #standalone_syntaxes

Methods included from DynamicAnalysis

#register_request_for_dynamic_analysis

Class Method Details

.target_method?(receiver_node, method_name) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/transpec/syntax/raise_error.rb', line 12

def self.target_method?(receiver_node, method_name)
  receiver_node.nil? && method_name == :raise_error
end

Instance Method Details

#remove_error_specification_with_negative_expectation!Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/transpec/syntax/raise_error.rb', line 16

def remove_error_specification_with_negative_expectation!
  return if expectation.positive?

  _receiver_node, _method_name, *arg_nodes = *node
  return if arg_nodes.empty?

  remove(parentheses_range)

  register_record
end