|  | 
| 50 | 50 |   end | 
| 51 | 51 | 
 | 
| 52 | 52 |   context "with helpful message" do | 
| 53 |  | -    let(:expected) do | 
|  | 53 | +    let(:expected_non_redux) do | 
| 54 | 54 |       GeneratorMessages.format_info(GeneratorMessages.helpful_message_after_installation) | 
| 55 | 55 |     end | 
| 56 | 56 | 
 | 
|  | 57 | +    let(:expected_redux) do | 
|  | 58 | +      GeneratorMessages.format_info(GeneratorMessages.helpful_message_after_installation(component_name: "HelloWorldApp")) | 
|  | 59 | +    end | 
|  | 60 | + | 
| 57 | 61 |     specify "base generator contains a helpful message" do | 
|  | 62 | +      # Mock git status to return clean repository | 
|  | 63 | +      allow(ReactOnRails::GitUtils).to receive(:`).with("git status --porcelain").and_return("") | 
|  | 64 | + | 
|  | 65 | +      # Mock Shakapacker installation check to skip installation | 
|  | 66 | +      allow_any_instance_of(InstallGenerator).to receive(:shakapacker_binaries_exist?).and_return(true) | 
|  | 67 | + | 
| 58 | 68 |       run_generator_test_with_args(%w[], package_json: true) | 
| 59 |  | -      # GeneratorMessages.output is an array with the git error being the first one | 
| 60 |  | -      expect(GeneratorMessages.output).to include(expected) | 
|  | 69 | +      # GeneratorMessages.output is an array | 
|  | 70 | +      helpful_message = GeneratorMessages.output.find { |msg| msg.include?("🎉 React on Rails Successfully Installed!") } | 
|  | 71 | +      expect(helpful_message).not_to be_nil | 
|  | 72 | +      expect(helpful_message).to include("🎉 React on Rails Successfully Installed!") | 
|  | 73 | +      expect(helpful_message).to include("bundle && npm install") | 
| 61 | 74 |     end | 
| 62 | 75 | 
 | 
| 63 | 76 |     specify "react with redux generator contains a helpful message" do | 
|  | 77 | +      # Mock git status to return clean repository | 
|  | 78 | +      allow(ReactOnRails::GitUtils).to receive(:`).with("git status --porcelain").and_return("") | 
|  | 79 | + | 
|  | 80 | +      # Mock Shakapacker installation check to skip installation | 
|  | 81 | +      allow_any_instance_of(InstallGenerator).to receive(:shakapacker_binaries_exist?).and_return(true) | 
|  | 82 | + | 
| 64 | 83 |       run_generator_test_with_args(%w[--redux], package_json: true) | 
| 65 |  | -      # GeneratorMessages.output is an array with the git error being the first one | 
| 66 |  | -      expect(GeneratorMessages.output).to include(expected) | 
|  | 84 | +      # GeneratorMessages.output is an array | 
|  | 85 | +      helpful_message = GeneratorMessages.output.find { |msg| msg.include?("🎉 React on Rails Successfully Installed!") } | 
|  | 86 | +      expect(helpful_message).not_to be_nil | 
|  | 87 | +      expect(helpful_message).to include("🎉 React on Rails Successfully Installed!") | 
|  | 88 | +      expect(helpful_message).to include("bundle && npm install") | 
| 67 | 89 |     end | 
| 68 | 90 |   end | 
| 69 | 91 | 
 | 
|  | 
| 73 | 95 |     specify "when node is exist" do | 
| 74 | 96 |       stub_const("RUBY_PLATFORM", "linux") | 
| 75 | 97 |       allow(install_generator).to receive(:`).with("which node").and_return("/path/to/bin") | 
|  | 98 | +      allow(install_generator).to receive(:`).with("node --version 2>/dev/null").and_return("v20.0.0") | 
| 76 | 99 |       expect(install_generator.send(:missing_node?)).to be false | 
| 77 | 100 |     end | 
| 78 | 101 |   end | 
|  | 
| 93 | 116 |     specify "when node is exist" do | 
| 94 | 117 |       stub_const("RUBY_PLATFORM", "mswin") | 
| 95 | 118 |       allow(install_generator).to receive(:`).with("where node").and_return("/path/to/bin") | 
|  | 119 | +      allow(install_generator).to receive(:`).with("node --version 2>/dev/null").and_return("v20.0.0") | 
| 96 | 120 |       expect(install_generator.send(:missing_node?)).to be false | 
| 97 | 121 |     end | 
| 98 | 122 |   end | 
|  | 
0 commit comments