From 9e24cff30b825855254aeaebbce025ac104d60e4 Mon Sep 17 00:00:00 2001 From: Andy Waite Date: Fri, 15 Nov 2024 13:01:16 -0600 Subject: [PATCH] Use predicates in tests for checking visibility (#2859) --- .../test/classes_and_modules_test.rb | 4 ++-- lib/ruby_indexer/test/constant_test.rb | 16 ++++++++-------- lib/ruby_indexer/test/method_test.rb | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/ruby_indexer/test/classes_and_modules_test.rb b/lib/ruby_indexer/test/classes_and_modules_test.rb index 61351d4ac..4e3abdf20 100644 --- a/lib/ruby_indexer/test/classes_and_modules_test.rb +++ b/lib/ruby_indexer/test/classes_and_modules_test.rb @@ -302,10 +302,10 @@ class D; end RUBY b_const = @index["A::B"].first - assert_equal(Entry::Visibility::PRIVATE, b_const.visibility) + assert_predicate(b_const, :private?) c_const = @index["A::C"].first - assert_equal(Entry::Visibility::PRIVATE, c_const.visibility) + assert_predicate(c_const, :private?) d_const = @index["A::D"].first assert_equal(Entry::Visibility::PUBLIC, d_const.visibility) diff --git a/lib/ruby_indexer/test/constant_test.rb b/lib/ruby_indexer/test/constant_test.rb index cf0f83329..30faa0aac 100644 --- a/lib/ruby_indexer/test/constant_test.rb +++ b/lib/ruby_indexer/test/constant_test.rb @@ -130,13 +130,13 @@ class A RUBY b_const = @index["A::B"].first - assert_equal(Entry::Visibility::PRIVATE, b_const.visibility) + assert_predicate(b_const, :private?) c_const = @index["A::C"].first - assert_equal(Entry::Visibility::PRIVATE, c_const.visibility) + assert_predicate(c_const, :private?) d_const = @index["A::D"].first - assert_equal(Entry::Visibility::PUBLIC, d_const.visibility) + assert_predicate(d_const, :public?) end def test_marking_constants_as_private_reopening_namespaces @@ -163,13 +163,13 @@ module B RUBY a_const = @index["A::B::CONST_A"].first - assert_equal(Entry::Visibility::PRIVATE, a_const.visibility) + assert_predicate(a_const, :private?) b_const = @index["A::B::CONST_B"].first - assert_equal(Entry::Visibility::PRIVATE, b_const.visibility) + assert_predicate(b_const, :private?) c_const = @index["A::B::CONST_C"].first - assert_equal(Entry::Visibility::PRIVATE, c_const.visibility) + assert_predicate(c_const, :private?) end def test_marking_constants_as_private_with_receiver @@ -187,10 +187,10 @@ module B RUBY a_const = @index["A::B::CONST_A"].first - assert_equal(Entry::Visibility::PRIVATE, a_const.visibility) + assert_predicate(a_const, :private?) b_const = @index["A::B::CONST_B"].first - assert_equal(Entry::Visibility::PRIVATE, b_const.visibility) + assert_predicate(b_const, :private?) end def test_indexing_constant_aliases diff --git a/lib/ruby_indexer/test/method_test.rb b/lib/ruby_indexer/test/method_test.rb index 809980e18..312730188 100644 --- a/lib/ruby_indexer/test/method_test.rb +++ b/lib/ruby_indexer/test/method_test.rb @@ -141,7 +141,7 @@ def bar; end # The first entry points to the location of the module_function call assert_equal("Test", first_entry.owner.name) assert_instance_of(Entry::Module, first_entry.owner) - assert_equal(Entry::Visibility::PRIVATE, first_entry.visibility) + assert_predicate(first_entry, :private?) # The second entry points to the public singleton method assert_equal("Test::", second_entry.owner.name) assert_instance_of(Entry::SingletonClass, second_entry.owner)