Skip to content

Commit bb20cd7

Browse files
Fix: Update RSC bundle tests to mock Pro configuration correctly
Fixed 3 test failures in utils_spec.rb that were caused by mocking non-existent ReactOnRails.configuration.rsc_bundle_js_file. Changes: - Updated tests to mock ReactOnRailsPro.configuration instead - Added proper Pro gem presence mocking with stub_const - Tests now correctly verify open-source bundle_js_file_path behavior when RSC bundles are present with Pro gem installed - Applied RuboCop auto-corrections for style compliance The open-source bundle_js_file_path function correctly handles RSC bundles by checking Pro configuration (lines 117-121 in utils.rb), so these tests ensure that behavior works as expected. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 18d19eb commit bb20cd7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

spec/react_on_rails/utils_spec.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,19 @@ def mock_dev_server_running
244244
let(:public_path) { File.expand_path(File.join(packer_public_output_path, rsc_bundle_name)) }
245245
let(:ssr_generated_path) { File.expand_path(File.join("ssr-generated", rsc_bundle_name)) }
246246

247+
before do
248+
# Mock Pro gem being available
249+
allow(described_class).to receive(:react_on_rails_pro?).and_return(true)
250+
stub_const("ReactOnRailsPro", Module.new)
251+
pro_config = double("ProConfiguration")
252+
allow(ReactOnRailsPro).to receive(:configuration).and_return(pro_config)
253+
allow(pro_config).to receive_messages(rsc_bundle_js_file: rsc_bundle_name,
254+
react_server_client_manifest_file: nil)
255+
end
256+
247257
context "with enforce_private_server_bundles=false" do
248258
before do
249259
mock_missing_manifest_entry(rsc_bundle_name)
250-
allow(ReactOnRails).to receive_message_chain("configuration.rsc_bundle_js_file")
251-
.and_return(rsc_bundle_name)
252260
allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_output_path")
253261
.and_return("ssr-generated")
254262
allow(ReactOnRails).to receive_message_chain("configuration.enforce_private_server_bundles")
@@ -283,8 +291,6 @@ def mock_dev_server_running
283291
context "with enforce_private_server_bundles=true" do
284292
before do
285293
mock_missing_manifest_entry(rsc_bundle_name)
286-
allow(ReactOnRails).to receive_message_chain("configuration.rsc_bundle_js_file")
287-
.and_return(rsc_bundle_name)
288294
allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_output_path")
289295
.and_return("ssr-generated")
290296
allow(ReactOnRails).to receive_message_chain("configuration.enforce_private_server_bundles")

0 commit comments

Comments
 (0)