You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve CONTRIBUTING.md with comprehensive generator testing documentation
- Add manual generator testing workflow with systematic approach
- Document testing for both Shakapacker scenarios (pre-installed vs fresh install)
- Include specific commit testing procedures for 81c66fa and bc69dcd
- Add troubleshooting section for common generator testing issues
- Document pre-commit requirements for linting and formatting
- Provide clean baseline testing process using git tags
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+166Lines changed: 166 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -268,6 +268,112 @@ The generators are covered by generator tests using Rails's generator testing he
268
268
269
269
`rake run_rspec:shakapacker_examples_basic` is a great way to run tests on one generator. Once that works, you should run `rake run_rspec:shakapacker_examples`. Be aware that this will create a huge number of files under a `/gen-examples` directory. You should be sure to exclude this directory from your IDE and delete it once your testing is done.
270
270
271
+
#### Manual Generator Testing Workflow
272
+
273
+
For comprehensive testing of generator changes, use this manual testing workflow with dedicated test applications:
274
+
275
+
**1. Set up test application with clean baseline:**
276
+
277
+
```bash
278
+
# Navigate to test app directory (replace with your test app)
- Development server starts successfully with `bin/dev`
375
+
- Console output shows expected messages and minimal warnings
376
+
271
377
#### Testing Generator with Yalc for React Component Functionality
272
378
273
379
When testing the install generator with new Rails apps, you need to use **yalc** for the JavaScript package to ensure React components work correctly. The Ruby gem path reference is insufficient for client-side rendering.
@@ -312,6 +418,66 @@ bin/dev
312
418
313
419
**Note**: Resource preload warnings in development modes are normal and can be ignored. They occur because Shakapacker generates preload tags but scripts load asynchronously. Production mode eliminates most of these warnings.
314
420
421
+
#### Generator Testing Troubleshooting
422
+
423
+
**Common Issues and Solutions:**
424
+
425
+
1.**React components not rendering (empty divs)**
426
+
-**Cause**: Missing yalc setup for JavaScript package
427
+
-**Solution**: Follow yalc setup steps above after running generator
428
+
429
+
2.**Generator fails with Shakapacker errors**
430
+
-**Cause**: Conflicting Shakapacker versions or incomplete installation
431
+
-**Solution**: Clean reset and ensure consistent Shakapacker version across tests
432
+
433
+
3.**Babel configuration conflicts during yalc development**
434
+
-**Cause**: Both `babel.config.js` and `package.json` "babel" section defining presets
435
+
-**Solution**: Remove "babel" section from `package.json`, keep only `babel.config.js`
436
+
437
+
4.**"Package.json not found" errors**
438
+
-**Cause**: Generator trying to access non-existent package.json files
439
+
-**Solution**: Test with commits that fix this specific issue (e.g., bc69dcd0)
440
+
441
+
5.**Port conflicts during testing**
442
+
-**Cause**: Multiple development servers running
443
+
-**Solution**: Run `bin/dev kill` before starting new test servers
444
+
445
+
**Testing Best Practices:**
446
+
- Always use the double clean command: `git clean -fd && git reset --hard && git clean -fd`
447
+
- Test both Shakapacker scenarios for comprehensive coverage
448
+
- Document exact error messages and steps to reproduce
449
+
- Verify React component interactivity, not just rendering
450
+
- Test all development modes: `bin/dev`, `bin/dev static`, `bin/dev prod`
451
+
452
+
## Pre-Commit Requirements
453
+
454
+
**CRITICAL**: Before committing any changes, always run the following commands to ensure code quality:
455
+
456
+
```bash
457
+
# Navigate to the main react_on_rails directory
458
+
cd react_on_rails/
459
+
460
+
# Run Prettier for JavaScript/TypeScript formatting
461
+
yarn run format
462
+
463
+
# Run ESLint for JavaScript/TypeScript linting
464
+
yarn run lint
465
+
466
+
# Run RuboCop for Ruby linting and formatting
467
+
rake lint:rubocop
468
+
469
+
# Or run all linters together
470
+
rake lint
471
+
```
472
+
473
+
**Automated checks:**
474
+
- Format all JavaScript/TypeScript files with Prettier
475
+
- Check and fix linting issues with ESLint
476
+
- Check and fix Ruby style issues with RuboCop
477
+
- Ensure all tests pass before pushing
478
+
479
+
**Tip**: Set up your IDE to run these automatically on save to catch issues early.
480
+
315
481
### Linting
316
482
317
483
All linting is performed from the docker container for CI. You will need docker and docker-compose installed locally to lint code changes via the lint container. You can lint locally by running `npm run lint && npm run flow`
0 commit comments