Skip to content

Add test for private method inheritance visibility#8

Open
nikitakar9862 wants to merge 3 commits into
low-rb:mainfrom
nikitakar9862:add-private-inheritance-test
Open

Add test for private method inheritance visibility#8
nikitakar9862 wants to merge 3 commits into
low-rb:mainfrom
nikitakar9862:add-private-inheritance-test

Conversation

@nikitakar9862

Copy link
Copy Markdown

Summary

Adds a test for private method inheritance using a fixture file.

Details

This test checks that:

  • private visibility is correctly set in the parent class
  • it does not incorrectly affect the subclass

Context

Related to Issue #4
This is based on the suggested subclass access scenario, where private methods in Ruby are inherited and can be called by subclasses.

@maedi brother, Happy to cover additional cases if needed.

@maedi

maedi commented Apr 20, 2026

Copy link
Copy Markdown
Member

Instead of a unit test, this can be a feature test. The test isn't really testing inheritance, it's testing if a class with a private method is detected to have one, and a class without a private method is detected not to have one. The child inheriting from the parent doesn't really change things, as Lowkey is just focusing on the methods defined in each file, and is not concerned with what methods will be inherited... it doesn't predict what will happen when classes are inherited, it just describes the class it sees. So a better test would be a feature test called something like "detects_private_methods_spec.rb" and the inheritance < Parent could be removed as it's not needed

@nikitakar9862

Copy link
Copy Markdown
Author

Thanks for the catch, @maedi brother I have updated the PR:

  1. Removed the inheritance logic ( < Parent ) from the fixture since Lowkey currently focuses on describing the methods it sees in the file rather than predicting inherited behavior.

  2. Moved the test from unit specs to a new feature spec (detects_private_methods_spec.rb).

  3. Renamed the fixture to visibility_test.rb to keep things clean.

Let me know if this looks better now.

Comment thread spec/features/detects_private_method_spec.rb Outdated
Comment thread spec/features/detects_private_method_spec.rb Outdated
Comment thread spec/features/detects_private_method_spec.rb Outdated
@maedi

maedi commented Apr 21, 2026

Copy link
Copy Markdown
Member

Looking good, getting there. We'll later add another test in this spec to actually get the list of private methods in this file. But we can do that later... I think there's an API for that in Lowkey but not sure, can leave for now, the foundations are there

@nikitakar9862

Copy link
Copy Markdown
Author

Done @maedi brother. Added the missing newlines, cleaned up the redundant expectation, and updated the spec title. Ready for another look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants