Class: Solargraph::Rspec::Correctors::LetMethodsCorrector

Inherits:
Base
  • Object
show all
Defined in:
lib/solargraph/rspec/correctors/let_methods_corrector.rb

Overview

Defines let-like methods in the example group block

Direct Known Subclasses

SubjectMethodCorrector

Instance Attribute Summary

Attributes inherited from Base

#added_pins, #namespace_pins, #rspec_walker

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Solargraph::Rspec::Correctors::Base

Instance Method Details

#correct(_source_map) ⇒ void

This method returns an undefined value.

Parameters:

  • source_map (Solargraph::SourceMap)


12
13
14
15
16
17
18
19
20
# File 'lib/solargraph/rspec/correctors/let_methods_corrector.rb', line 12

def correct(_source_map)
  rspec_walker.on_let_method do |let_name, location_range, fake_method_ast|
    namespace_pin = closest_namespace_pin(namespace_pins, location_range.start.line)
    next unless namespace_pin

    pin = rspec_let_method(namespace_pin, let_name, location_range, fake_method_ast)
    add_pin(pin)
  end
end