@@ -27,6 +27,17 @@ class PlainReactOnRailsHelper
2727      rsc_support_enabled? : false 
2828    ) 
2929
30+     # Stub ReactOnRailsPro::Utils.pro_attribution_comment for all tests 
31+     # since react_on_rails_pro? is set to true by default 
32+     pro_module  =  Module . new 
33+     utils_module  =  Module . new  do 
34+       def  self . pro_attribution_comment 
35+         "<!-- Powered by React on Rails Pro (c) ShakaCode | Licensed -->" 
36+       end 
37+     end 
38+     stub_const ( "ReactOnRailsPro" ,  pro_module ) 
39+     stub_const ( "ReactOnRailsPro::Utils" ,  utils_module ) 
40+ 
3041    # Configure immediate_hydration to true for tests since they expect that behavior 
3142    ReactOnRails . configure  do  |config |
3243      config . immediate_hydration  =  true 
@@ -641,15 +652,10 @@ def helper.append_javascript_pack_tag(name, **options)
641652      let ( :pro_comment )  {  "<!-- Powered by React on Rails Pro (c) ShakaCode | Licensed -->"  } 
642653
643654      before  do 
644-         pro_module  =  Module . new 
645-         utils_module  =  Module . new  do 
646-           def  self . pro_attribution_comment ;  end 
647-         end 
648-         stub_const ( "ReactOnRailsPro" ,  pro_module ) 
649-         stub_const ( "ReactOnRailsPro::Utils" ,  utils_module ) 
650- 
655+         # ReactOnRailsPro::Utils is already stubbed in global before block 
656+         # Just override the return value for this context 
651657        allow ( ReactOnRails ::Utils ) . to  receive ( :react_on_rails_pro? ) . and_return ( true ) 
652-         allow ( utils_module ) . to  receive ( :pro_attribution_comment ) . and_return ( pro_comment ) 
658+         allow ( ReactOnRailsPro :: Utils ) . to  receive ( :pro_attribution_comment ) . and_return ( pro_comment ) 
653659      end 
654660
655661      it  "returns the Pro attribution comment"  do 
0 commit comments