Class: Transpec::Syntax::RSpecConfigure

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

Defined Under Namespace

Classes: FrameworkConfiguration, UnknownSyntaxError

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#node, #report, #runtime_data, #source_rewriter

Class Method Summary collapse

Methods inherited from Transpec::Syntax

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

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

.add_framework_configuration(type, config_method_name) ⇒ Object



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

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)


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

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
  Util.const_name(receiver_node) == 'RSpec' && method_name == :configure
end