Class: Transpec::Syntax::RaiseError

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

Defined Under Namespace

Classes: RecordBuilder

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#node, #project, #report, #runtime_data, #source_rewriter

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::Send::TargetDetection

#conversion_target?

Methods included from Mixin::OwnedMatcher

#initialize

Methods inherited from Transpec::Syntax

#add_record, #conversion_target?, #dependent_syntaxes, #expression_range, #initialize, #inspect, #parent_node, #rspec_version, snake_case_name, standalone?, #static_context_inspector

Methods included from Collection

#all_syntaxes, #inherited, #mixins, #require_all, #standalone_syntaxes

Methods included from DynamicAnalysis

#register_dynamic_analysis_request

Instance Method Details

#dynamic_analysis_target?Boolean

Returns:

  • (Boolean)


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

def dynamic_analysis_target?
  super && receiver_node.nil? && method_name == :raise_error
end

#remove_error_specification_with_negative_expectation!Object



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

def remove_error_specification_with_negative_expectation!
  return if expectation.positive?
  return unless specific_error?
  remove(parentheses_range)
  add_record(RecordBuilder.build(self))
end

#specific_class?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/transpec/syntax/raise_error.rb', line 27

def specific_class?
  specific_error? && arg_nodes.first.const_type?
end

#specific_error?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/transpec/syntax/raise_error.rb', line 23

def specific_error?
  !arg_nodes.empty?
end

#specific_message?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
# File 'lib/transpec/syntax/raise_error.rb', line 31

def specific_message?
  if specific_class?
    arg_nodes.count >= 2
  else
    specific_error?
  end
end