Commit 91f2e16
authored
Fix main generator pretend spec isolation (#4147)
## Why
The default branch is currently failing `Rspec test for gem` on `main`
in the generator shard:
- Run:
https://github.com/shakacode/react_on_rails/actions/runs/27869267839
- Failed jobs: `rspec-package-tests (4.0, latest, generators)` and
`rspec-package-tests (3.3, minimum, generators)`
- Failed example:
`spec/react_on_rails/generators/install_generator_spec.rb:3717`
The failure was not caused by the most recent Pro streaming PR. The same
generator failure appears on the prior pushed commit and traces back to
the custom Shakapacker-root generator work in #4130. A focused ordered
repro showed the issue:
```bash
cd react_on_rails && bundle exec rspec \
spec/react_on_rails/generators/install_generator_spec.rb:564 \
spec/react_on_rails/generators/install_generator_spec.rb:590 \
spec/react_on_rails/generators/install_generator_spec.rb:3717
```
Before this patch, that sequence failed because earlier examples left
`config/shakapacker.yml` in the shared generator destination. The
pretend-mode example used `expect(File).not_to receive(:read)`, which
accidentally forbade the legitimate config read used to resolve
Shakapacker paths. The behavior the test meant to protect is narrower:
pretend mode must not read the copied Redux Tailwind client entry,
because pretend mode does not create that file.
## What changed
- Adds an explicit `config/shakapacker.yml` fixture to the pretend-mode
example.
- Allows normal `File.read` calls while asserting the generated Redux
client entry is not read.
- Keeps the production generator code unchanged.
## Validation
- `git diff --check` -> passed.
- `cd react_on_rails && bundle exec rspec
spec/react_on_rails/generators/install_generator_spec.rb:564
spec/react_on_rails/generators/install_generator_spec.rb:590
spec/react_on_rails/generators/install_generator_spec.rb:3717` -> 4
examples, 0 failures.
- `cd react_on_rails && BUNDLE_GEMFILE=../Gemfile bundle exec rubocop
spec/react_on_rails/generators/install_generator_spec.rb` -> 1 file
inspected, no offenses.
- `codex review --uncommitted` -> no actionable correctness issues.
- Pre-commit hook -> trailing-newlines, Ruby autofix/RuboCop passed for
the changed spec.
- Pre-push hook -> branch Ruby RuboCop and markdown-links passed.
## Process triage
Process Gap Disposition: `checklist+replay`.
- Motivating miss: #4130 recorded focused validation for
`install_generator_spec.rb:3717`, but the default-branch failure
required replaying that example after earlier custom-root generator
examples that leave `config/shakapacker.yml` in the shared destination.
- Replay evidence: the ordered repro above failed on `main` before this
patch and passed after this patch.
- Non-goal: do not add a broad prose-only rule or a full generator-suite
requirement for every small generator PR.
Merge queue would reduce stale-base/concurrency merges, but it would not
have caught this exact issue unless the queue runs the same generator
shard before landing. The actionable process improvement is to include
ordered replay when adding generator examples that share
`dummy-for-generators`, especially when new examples leave Shakapacker
config or other shared files behind.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Test-only change to generator spec isolation; no production generator
behavior modified.
>
> **Overview**
> Fixes flaky generator CI by tightening the **pretend-mode Redux +
Tailwind** example in `install_generator_spec.rb`, without changing
generator code.
>
> The example now seeds its own `config/shakapacker.yml` so Shakapacker
path resolution does not depend on leftovers from earlier examples in
the shared `dummy-for-generators` destination. It stubs `File.read` with
`and_call_original` and only forbids reading the Redux Tailwind client
entry (`HelloWorldApp.client.jsx`), which matches the real behavior:
pretend mode may read config but must not read the copied client file to
inject the stylesheet import.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ace8804. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 19a01db commit 91f2e16
1 file changed
Lines changed: 9 additions & 1 deletion
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3717 | 3717 | | |
3718 | 3718 | | |
3719 | 3719 | | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
3720 | 3727 | | |
3721 | 3728 | | |
3722 | 3729 | | |
3723 | 3730 | | |
| 3731 | + | |
3724 | 3732 | | |
3725 | | - | |
| 3733 | + | |
3726 | 3734 | | |
3727 | 3735 | | |
3728 | 3736 | | |
| |||
0 commit comments