Skip to content

Commit c39127c

Browse files
Fix: Properly stub ReactOnRailsPro module with configuration method
Fixed test failures caused by attempting to mock configuration on an empty Module stub. The stubbed ReactOnRailsPro module now properly implements the configuration getter/setter methods. Changes: - Created proper mock Pro module with working configuration methods - Set configuration directly instead of using allow().to receive() - Matches the real Pro gem's module structure This fixes 4 test failures: - returns private path when it exists even if public path also exists - fallbacks to public path when private path does not exist and public path exists - returns configured path if both private and public paths do not exist - enforces private RSC bundles and never checks public directory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent b4acd73 commit c39127c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spec/react_on_rails/utils_spec.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,23 @@ def mock_dev_server_running
247247
before do
248248
# Mock Pro gem being available
249249
allow(described_class).to receive(:react_on_rails_pro?).and_return(true)
250-
stub_const("ReactOnRailsPro", Module.new)
250+
251+
# Create a mock Pro module with configuration method
252+
pro_module = Module.new do
253+
def self.configuration
254+
@configuration
255+
end
256+
257+
def self.configuration=(config)
258+
@configuration = config
259+
end
260+
end
261+
stub_const("ReactOnRailsPro", pro_module)
262+
251263
pro_config = double("ProConfiguration") # rubocop:disable RSpec/VerifiedDoubles
252-
allow(ReactOnRailsPro).to receive(:configuration).and_return(pro_config)
253264
allow(pro_config).to receive_messages(rsc_bundle_js_file: rsc_bundle_name,
254265
react_server_client_manifest_file: nil)
266+
ReactOnRailsPro.configuration = pro_config
255267
end
256268

257269
context "with enforce_private_server_bundles=false" do

0 commit comments

Comments
 (0)