Class: Transpec::Syntax::RSpecConfigure

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

Defined Under Namespace

Classes: FrameworkConfiguration

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#ancestor_nodes, #in_example_group_context, #node, #source_rewriter

Class Method Summary collapse

Methods inherited from Transpec::Syntax

all, #expression_range, inherited, #initialize, #parent_node, snake_case_name

Constructor Details

This class inherits a constructor from Transpec::Syntax

Class Method Details

.add_framework_configuration(type, config_method_name) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/transpec/syntax/rspec_configure.rb', line 92

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) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
88
89
90
# File 'lib/transpec/syntax/rspec_configure.rb', line 85

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