Class: Transpec::Syntax::RSpecConfigure::Framework

Inherits:
Object
  • Object
show all
Includes:
ConfigModification, SyntaxConfig, Transpec::Syntax::Rewritable
Defined in:
lib/transpec/syntax/rspec_configure/framework.rb

Overview

This cannot be a Syntax class since this can be instanciated and used even when there’s no corresponding node in the existing code.

Direct Known Subclasses

Expectations, Mocks

Defined Under Namespace

Modules: SyntaxConfig

Constant Summary

Constants included from Util

Util::LITERAL_TYPES, Util::WHITESPACES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SyntaxConfig

#syntaxes, #syntaxes=

Methods included from ConfigModification::ConfigAddition

#add_config!, #empty_block_body?

Methods included from Util

beginning_of_line_range, block_node_taken_by_method, chainable_source, const_name, contain_here_document?, each_backward_chained_node, each_forward_chained_node, each_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?, proc_literal?, range_from_arg

Constructor Details

#initialize(rspec_configure) ⇒ Framework

Returns a new instance of Framework.



15
16
17
# File 'lib/transpec/syntax/rspec_configure/framework.rb', line 15

def initialize(rspec_configure)
  @rspec_configure = rspec_configure
end

Instance Attribute Details

#rspec_configureObject (readonly)

Returns the value of attribute rspec_configure.



13
14
15
# File 'lib/transpec/syntax/rspec_configure/framework.rb', line 13

def rspec_configure
  @rspec_configure
end

Instance Method Details

#add_record(*args) ⇒ Object



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

def add_record(*args)
  rspec_configure.add_record(*args)
end

#block_nodeObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/transpec/syntax/rspec_configure/framework.rb', line 27

def block_node
  return @block_node if instance_variable_defined?(:@block_node)

  @block_node = rspec_configure.block_node.each_descendant(:block).find do |block_node|
    send_node = block_node.children.first
    receiver_node, method_name, = *send_node
    next unless receiver_node == s(:lvar, rspec_configure.block_arg_name)
    method_name == block_method_name
    # TODO: Check expectation framework.
  end
end

#source_rewriterObject



19
20
21
# File 'lib/transpec/syntax/rspec_configure/framework.rb', line 19

def source_rewriter
  rspec_configure.source_rewriter
end