Class: Solargraph::Rspec::Correctors::DescribedClassCorrector

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

Overview

Defines ‘described_class` method in the example group block

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/described_class_corrector.rb', line 12

def correct(_source_map)
  rspec_walker.on_described_class do |described_class_name, location_range|
    namespace_pin = closest_namespace_pin(namespace_pins, location_range.start.line)
    next unless namespace_pin

    described_class_pin = rspec_described_class_method(namespace_pin, location_range, described_class_name)
    add_pin(described_class_pin)
  end
end