Class: Solargraph::Rspec::Correctors::DslMethodsCorrector
- Defined in:
- lib/solargraph/rspec/correctors/dsl_methods_corrector.rb
Overview
Corrects RSpec DSL methods in the specs by adding superclass references to the namespace pins (ie. contexts). The DSLs methods are generated by rspec-core YARD annotations defined in [RSpec::Core::ExampleGroup]
Instance Attribute Summary
Attributes inherited from Base
#added_pins, #namespace_pins, #rspec_walker
Instance Method Summary collapse
Methods inherited from Base
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.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/solargraph/rspec/correctors/dsl_methods_corrector.rb', line 14 def correct(_source_map) rspec_walker.after_walk do namespace_pins.each_with_index do |namespace_pin, index| super_class = if index.zero? 'RSpec::Core::ExampleGroup' else namespace_pins[index - 1].path end add_pin( Pin::Reference::Superclass.new( location: namespace_pin.location, closure: namespace_pin, name: super_class ) ) end end end |