Sha256: 77b4bb36a0407ad7cf005f6fdd364efd65fe432d883b83d75373308814655c91

Contents?: true

Size: 1.25 KB

Versions: 32

Compression:

Stored size: 1.25 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_entries
      assert_empty(@index.instance_variable_get(:@entries), "Expected nothing to be indexed")
    end

    def assert_no_entry(entry)
      refute(@index.instance_variable_get(:@entries).key?(entry), "Expected '#{entry}' to not be indexed")
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
ruby-lsp-0.16.6 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.16.5 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.16.4 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.16.3 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.16.2 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.16.1 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.16.0 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.15.0 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.14.6 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.14.5 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.14.4 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.14.3 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.14.2 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.14.1 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.14.0 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.13.4 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.13.3 lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.13.2 lib/ruby_indexer/test/test_case.rb
study_line-0.1.6 vendor/bundle/ruby/3.2.0/gems/ruby-lsp-0.12.1/lib/ruby_indexer/test/test_case.rb
ruby-lsp-0.13.1 lib/ruby_indexer/test/test_case.rb