Skip to content

Commit e03dd57

Browse files
Use stub_const to properly mock ReactOnRailsPro module
The ReactOnRailsPro constant doesn't exist in the dummy app environment, so we need to use stub_const to create the module and its nested Helper module before we can stub their methods. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fa1b1a3 commit e03dd57

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

spec/dummy/spec/helpers/react_on_rails_helper_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ class PlainReactOnRailsHelper
2727
)
2828

2929
# Mock Pro gem configuration and helper for immediate_hydration
30-
pro_config = Struct.new(:immediate_hydration).new(true)
31-
allow(ReactOnRailsPro).to receive(:configuration).and_return(pro_config)
30+
stub_const("ReactOnRailsPro", Module.new do
31+
def self.configuration
32+
@configuration ||= Struct.new(:immediate_hydration).new(true)
33+
end
34+
end)
35+
36+
stub_const("ReactOnRailsPro::Helper", Module.new)
3237
allow(ReactOnRailsPro::Helper).to receive(:enhance_component_script_data) do |args|
3338
if args[:render_options].immediate_hydration
3439
dom_id = args[:render_options].dom_id

0 commit comments

Comments
 (0)