Sha256: 780b51a8150dbc51f5093568b8818a3b60d516d472c2beca69eede5055298dbe

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

# typed: true
# frozen_string_literal: true

require "test_helper"

module RubyIndexer
  class TestCase < Minitest::Test
    def setup
      @index = Index.new
    end

    private

    def index(source)
      @index.index_single(IndexablePath.new(nil, "/fake/path/foo.rb"), source)
    end

    def assert_entry(expected_name, type, expected_location)
      entries = @index[expected_name]
      refute_empty(entries, "Expected #{expected_name} to be indexed")

      entry = entries.first
      assert_instance_of(type, entry, "Expected #{expected_name} to be a #{type}")

      location = entry.location
      location_string =
        "#{entry.file_path}:#{location.start_line - 1}-#{location.start_column}" \
          ":#{location.end_line - 1}-#{location.end_column}"

      assert_equal(expected_location, location_string)
    end

    def refute_entry(expected_name)
      entries = @index[expected_name]
      assert_nil(entries, "Expected #{expected_name} to not be indexed")
    end

    def assert_no_entry
      assert_empty(@index.instance_variable_get(:@entries), "Expected nothing to be indexed")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-lsp-0.11.2 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.11.1 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.11.0 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.10.1 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.10.0 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.9.4 lib/ruby_indexer/test/test_case.rb