Class: Transpec::Syntax::Pending

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

Constant Summary

Constants included from Util

Util::LITERAL_TYPES, Util::WHITESPACES

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 Util

beginning_of_line_range, block_node_taken_by_method, const_name, contain_here_document?, each_backward_chained_node, each_forward_chained_node, each_line_range, end_of_line_range, expand_range_to_adjacent_whitespaces, find_consecutive_whitespace_position, first_block_arg_name, here_document?, in_explicit_parentheses?, indentation_of_line, line_range, literal?, node_id, proc_literal?, range_from_arg

Methods inherited from Transpec::Syntax

#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

Constructor Details

This class inherits a constructor from Transpec::Syntax

Class Method Details

.conversion_target_node?(node, runtime_data = nil) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/transpec/syntax/pending.rb', line 12

def self.conversion_target_node?(node, runtime_data = nil)
  return false unless target_node?(node, runtime_data)

  # Check whether the context is example group to differenciate
  # RSpec::Core::ExampleGroup.pending (a relative of #it) and
  # RSpec::Core::ExampleGroup#pending (marks the example as pending in #it block).
  if runtime_data && runtime_data.run?(node)
    # If we have runtime data, check with it.
    runtime_data[node, :example_context?]
  else
    # Otherwise check statically.
    inspector = StaticContextInspector.new(node)
    inspector.scopes.last == :example
  end
end

.target_method?(receiver_node, method_name) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/transpec/syntax/pending.rb', line 28

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

Instance Method Details

#convert_deprecated_syntax!Object



37
38
39
40
41
42
43
# File 'lib/transpec/syntax/pending.rb', line 37

def convert_deprecated_syntax!
  if block_node
    unblock!
  else
    convert_to_skip!
  end
end