-
-
Notifications
You must be signed in to change notification settings - Fork 0
Use autoload
#16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use autoload
#16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces autoload-based lazy loading for Rails::AppEnv and updates related tests and configuration files accordingly.
- Replace multiple require_relative calls with autoload declarations in lib/rails/app_env.rb.
- Update test files and the Railtie configuration to reference the new autoloaded constants.
- Adjust configuration in test/dummy/config/application.rb to enable eager loading in CI environments.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/units/app_env/credentials_test.rb | Added test to confirm AlreadyInitializedError inherits from the correct error. |
test/units/app_env/console_test.rb | Updated console require and assertion to match namespace changes. |
test/features/credentials_test.rb | Modified path assertions to use the dummy_path helper. |
test/dummy/config/application.rb | Configured eager_load to activate when running in CI. |
lib/rails/rails_ext/credentials_command.rb | Marked the config method as private. |
lib/rails/app_env/railtie.rb | Updated initialization and console configuration to use autoloaded constants. |
lib/rails/app_env/credentials.rb | Changed error class inheritance to reference the autoloaded Error constant. |
lib/rails/app_env.rb | Removed require_relative calls and replaced them with autoload declarations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the AppEnv library to use Ruby’s autoload
for module components, cleans up Railtie initialization, and updates tests and dummy app config.
- Replace explicit
require_relative
calls withautoload
declarations inlib/rails/app_env.rb
- Simplify Railtie hooks to use scoped constants (
Credentials
andConsole
) and remove redundant requires - Update unit and feature tests to use
dummy_path
for credentials and adjust test requires; make dummy app’seager_load
conditional onENV["CI"]
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
test/units/app_env/credentials_test.rb | Add inheritance test for AlreadyInitializedError |
test/units/app_env/console_test.rb | Update test require and name for Console class |
test/features/credentials_test.rb | Use dummy_path helper for credentials file assertions |
test/dummy/config/application.rb | Make config.eager_load conditional on CI environment |
lib/rails/rails_ext/credentials_command.rb | Scope config method under private |
lib/rails/app_env/railtie.rb | Reference Credentials and Console directly; remove require_relative |
lib/rails/app_env/credentials.rb | Shorten AlreadyInitializedError superclass to Error |
lib/rails/app_env.rb | Introduce autoload declarations for AppEnv components |
Comments suppressed due to low confidence (1)
test/units/app_env/console_test.rb:3
- [nitpick] The test is trying to load
Rails::AppEnv::Console
but requires the internal IRBConsole. Consider requiringrails/app_env/console
(or the mainrails/app_env
entrypoint) so the AppEnv Console class is properly loaded.
require "rails/commands/console/irb_console"
No description provided.