Class: Transpec::Syntax::RSpecConfigure

Inherits:
Transpec::Syntax show all
Extended by:
Util
Defined in:
lib/transpec/syntax/rspec_configure.rb

Defined Under Namespace

Classes: FrameworkConfiguration, UnknownSyntaxError

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#ancestor_nodes, #node, #report, #runtime_data, #source_rewriter

Class Method Summary collapse

Methods included from Util

const_name, contain_here_document?, here_document?, in_parentheses?, indentation_of_line, proc_literal?

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

Constructor Details

This class inherits a constructor from Transpec::Syntax

Class Method Details

.add_framework_configuration(type, config_method_name) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/transpec/syntax/rspec_configure.rb', line 18

def self.add_framework_configuration(type, config_method_name)
  class_eval <<-END
    def #{type}_syntaxes
      #{type}_framework_configuration.syntaxes
    end

    def modify_#{type}_syntaxes!(syntaxes)
      #{type}_framework_configuration.modify_syntaxes!(syntaxes)
    end

    def #{type}_framework_configuration
      @#{type}_framework_configuration ||=
        FrameworkConfiguration.new(node, :#{config_method_name}, source_rewriter)
    end
  END
end

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

Returns:

  • (Boolean)


11
12
13
14
15
16
# File 'lib/transpec/syntax/rspec_configure.rb', line 11

def self.target_node?(node, runtime_data = nil)
  return false unless node && node.type == :block
  send_node = node.children.first
  receiver_node, method_name, *_ = *send_node
  const_name(receiver_node) == 'RSpec' && method_name == :configure
end