Ensure correct positioning of hook extensions relative to core modules#9
Merged
Ensure correct positioning of hook extensions relative to core modules#9
Conversation
- Enhance `HookApplier` with three distinct modes: no hooks, entries in ancestors, and interleaved entries with hooks. - Add `include_hooks_only` and `entries_in_ancestors?` methods for better inheritance handling. - Reverse hook iteration to enforce correct method resolution order. - Adjust DSL generator to call `included` directly for entry extensions.
- Introduce `entries_in_ancestors?`, `include_entries_with_hooks`, and `include_hooks_only` as private methods. - Enhance `HookApplier` class with additional handling for entries and hooks. - Mark methods as private to encapsulate internal logic.
…leaving - Update `DSL::Generator` spec to verify deferred entry inclusion for base class and interleaved inclusion with hooks for child classes. - Add tests for multi-level inheritance, ensuring hooks propagate correctly to descendants. - Enhance `HookApplier` spec with comprehensive scenarios for hook positioning (before and after) relative to entries, multi-hook applications, and deferred execution. - Introduce edge case tests for existing entries in ancestors and private methods like `entries_in_ancestors?`.
- Remove "(deferred)", "(interleave)", and similar labels from test titles for clarity and uniformity. - Reorder and group related tests in `DSL::Generator` spec to improve readability. - Replace "parent_class" with "base_class" in `inheritance isolation` tests to align with consistent terminology. - Remove unused `entries_in_ancestors?` tests from `HookApplier` spec to streamline focus on public behavior.
- Introduce deferred inclusion workflow, triggering `included` callback for entry extensions without immediately appending features to ancestors. - Document idempotency requirement for `self.included` callbacks in entry extensions. - Ensure proper interleaving of module inclusion and hooks by deferring actual module insertion until processed by Applier.
- Update `HookApplier` to manage deferred entry inclusion with hooks, ensuring correct method resolution order (MRO). - Refactor `entries_in_ancestors?` to check for all entries instead of any, enabling precise handling of partially included entries. - Improve documentation for hook inclusion logic and state-based operational modes. - Enhance method idempotency to allow seamless reprocessing of included entries and hooks.
- Enhance `DSL::Generator` spec with new test cases for hooks and entries in multi-level inheritance scenarios. - Add tests for propagating hooks through all ancestor levels. - Verify inheritance isolation for grandchild classes without explicit hooks. - Update `HookApplier` spec with expanded scenarios for before and after hooks. - Cover cases for individual hooks, combined hooks (both before and after), and duplication prevention in ancestors. - Ensure improved coverage for hook inclusion and inheritance behaviors across the specs.
- Simplify and unify naming in `DSL::Generator` and `HookApplier` specs, replacing redundant and inconsistent variable names (e.g., renaming `before_ext` to `before_extension`). - Restructure tests in `DSL::Generator` spec for clarity: - Group scenarios by hook levels (one level, every level, no hooks). - Rename test contexts for consistency (e.g., "multi-level with hooks at every level"). - Enhance `HookApplier` tests to ensure proper MRO (method resolution order) with hooks relative to entries: - Add scenarios for combined hooks, multi-hook order, and hook isolation. - Ensure hooks and entries propagate correctly across classes and descendants. - Improve readability and maintainability of test cases through better grouping and naming.
- Correct typo in variable name: `before_extensionension` → `before_extension`. - Update expectations and hook addition logic to align with the corrected name. - Ensure accurate naming improves readability and reduces potential confusion in the spec.
- Add detailed explanation about deferred `Module#include` behavior and interleaving with hooks in child classes. - Specify the contract for idempotent `self.included` implementation in entry extensions. - Improve documentation for lifecycle stages of entry inclusion across the class hierarchy.
- Extend `DSL::Generator` spec with tests to validate hook positioning relative to entries in grandchild classes. - Verify `before_hook` maintains correct ordering relative to entries across inherited modules. - Confirm `after_hook` appears above inherited entries in method resolution order (MRO). - Include explanatory comments on Ruby's `Module#include` limitations and their impact on MRO behavior.
- Update test descriptions in `DSL::Generator` spec to improve accuracy and readability. - Replace ambiguous terms like "defers entries" with clearer phrasing (e.g., "does not include entries"). - Consolidate overlapping test cases by grouping related assertions, simplifying structure. - Ensure test titles align with multi-level inheritance and hook propagation logic.
- Remove `grandchild` variable from multi-level inheritance tests to reduce redundancy. - Update tests to dynamically create grandchild classes within assertions. - Simplify test expectations for MRO validation with improved clarity and consistency. - Ensure alignment with prior improvements to the `DSL::Generator` spec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.