Skip to content

Commit 7e4b7dc

Browse files
justin808claude
andauthored
Add comprehensive --rsc-pro generator tests (#3098)
## Summary - Add missing test assertions for the `--rsc-pro` generator context to match the thoroughness of the `--rsc` tests - Verifies node-renderer.js creation, RSC bundle watcher in Procfile.dev, HelloServer replacing HelloWorld (controller + routes + components), hello_server and rsc_payload routes, and rscWebpackConfig.js The `--rsc-pro` generator mode implementation was completed in #2822, but the test coverage was incomplete — only version pinning and DEFAULT_ROUTE were verified. This closes the gap by adding route, component, Procfile, and webpack config assertions. Closes #2793 ## Test plan - [x] `bundle exec rspec react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb -e "with --rsc-pro"` — 12 examples, 0 failures - [x] `bundle exec rubocop` — no offenses 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: only adds RSpec assertions around generator output, with no production code changes. Main risk is increased test brittleness if templates evolve. > > **Overview** > Strengthens test coverage for the `react_on_rails:install --rsc-pro` path by asserting generation of `client/node-renderer.js`, the RSC bundle watcher entry in `Procfile.dev`, and the switch from `HelloWorld` scaffolding to `HelloServer`. > > Adds checks that `config/routes.rb` includes both `hello_server` and `rsc_payload`, and verifies RSC-specific webpack artifacts (`config/webpack/rscWebpackConfig.js` plus `RSCWebpackPlugin` usage and the `rscBundle` parameter in `serverWebpackConfig`). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1b5b1d1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Expanded test coverage for installation configuration validation, including scaffold setup and configuration file generation checks. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0610126 commit 7e4b7dc

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,65 @@ class ActiveSupport::TestCase
17321732
end
17331733
end
17341734

1735+
it "creates node-renderer.js" do
1736+
assert_file "client/node-renderer.js" do |content|
1737+
expect(content).to include("reactOnRailsProNodeRenderer")
1738+
expect(content).to include("require('react-on-rails-pro-node-renderer')")
1739+
end
1740+
end
1741+
1742+
it "adds RSC bundle watcher to Procfile.dev" do
1743+
assert_file "Procfile.dev" do |content|
1744+
expect(content).to include("RSC_BUNDLE_ONLY=true")
1745+
expect(content).to include("rsc-bundle:")
1746+
expect(content).to include("bin/shakapacker-watch --watch")
1747+
end
1748+
end
1749+
1750+
it "creates HelloServer instead of HelloWorld" do
1751+
assert_no_file "app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx"
1752+
assert_no_file "app/javascript/src/HelloWorld/ror_components/HelloWorld.server.jsx"
1753+
assert_no_file "app/controllers/hello_world_controller.rb"
1754+
assert_file "config/routes.rb" do |content|
1755+
expect(content).not_to include("hello_world")
1756+
end
1757+
1758+
assert_file "app/javascript/src/HelloServer/ror_components/HelloServer.jsx"
1759+
assert_file "app/javascript/src/HelloServer/components/HelloServer.jsx"
1760+
assert_file "app/javascript/src/HelloServer/components/LikeButton.jsx"
1761+
end
1762+
1763+
it "adds HelloServer route and RSC payload route" do
1764+
assert_file "config/routes.rb" do |content|
1765+
expect(content).to include("hello_server")
1766+
expect(content).to include("rsc_payload")
1767+
end
1768+
end
1769+
1770+
it "creates rscWebpackConfig.js" do
1771+
assert_file "config/webpack/rscWebpackConfig.js" do |content|
1772+
expect(content).to include("const serverWebpackModule = require('./serverWebpackConfig')")
1773+
expect(content).to include("const serverWebpackConfig = serverWebpackModule.default || serverWebpackModule")
1774+
expect(content).to include("serverWebpackConfig(true)")
1775+
expect(content).to include("rsc-bundle")
1776+
expect(content).to include("react-server")
1777+
end
1778+
end
1779+
1780+
it "serverWebpackConfig includes RSCWebpackPlugin import" do
1781+
assert_file "config/webpack/serverWebpackConfig.js" do |content|
1782+
expect(content).to include("RSCWebpackPlugin")
1783+
expect(content).to include("react-on-rails-rsc/WebpackPlugin")
1784+
end
1785+
end
1786+
1787+
it "serverWebpackConfig has rscBundle parameter" do
1788+
assert_file "config/webpack/serverWebpackConfig.js" do |content|
1789+
expect(content).to match(/configureServer\s*=\s*\(rscBundle\s*=\s*false\)/)
1790+
expect(content).to include("if (!rscBundle)")
1791+
end
1792+
end
1793+
17351794
it "sets DEFAULT_ROUTE to hello_server in bin/dev" do
17361795
assert_file "bin/dev" do |content|
17371796
expect(content).to include('DEFAULT_ROUTE = "hello_server"')

0 commit comments

Comments
 (0)