class RubyIndexer::EnhancementTest

def test_enhancing_indexing_configuration_dsl

def test_enhancing_indexing_configuration_dsl
  Class.new(Enhancement) do
    def on_call_node_enter(node) # rubocop:disable RubyLsp/UseRegisterWithHandlerMethod
      return unless @listener.current_owner
      name = node.name
      return unless name == :has_many
      arguments = node.arguments&.arguments
      return unless arguments
      association_name = arguments.first
      return unless association_name.is_a?(Prism::SymbolNode)
      @listener.add_method(
        association_name.value, #: as !nil
        association_name.location,
        [],
      )
    end
  end
  index(<<~RUBY)
    module ActiveSupport
      module Concern
        def self.extended(base)
          base.class_eval("def new_method(a); end")
        end
      end
    end
    module ActiveRecord
      module Associations
        extend ActiveSupport::Concern
        module ClassMethods
          def belongs_to(something); end
        end
      end
      class Base
        include Associations
      end
    end
    class User < ActiveRecord::Base
      has_many :posts
    end
  RUBY
  assert_entry("posts", Entry::Method, "/fake/path/foo.rb:23-11:23-17")
end