Skip to content

Commit

Permalink
Use predicates in tests for checking visibility (#2859)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 authored Nov 15, 2024
1 parent 27c6af7 commit 9e24cff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/ruby_indexer/test/classes_and_modules_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions lib/ruby_indexer/test/constant_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_indexer/test/method_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Class:Test>", second_entry.owner.name)
assert_instance_of(Entry::SingletonClass, second_entry.owner)
Expand Down

0 comments on commit 9e24cff

Please sign in to comment.