|
16 | 16 | $stdout = original_stdout |
17 | 17 | end |
18 | 18 |
|
| 19 | + def setup_script_execution |
| 20 | + # Mock ARGV to simulate no arguments (default HMR mode) |
| 21 | + stub_const("ARGV", []) |
| 22 | + # Mock pack generation |
| 23 | + allow_any_instance_of(Kernel).to receive(:system).with("bundle exec rake react_on_rails:generate_packs").and_return(true) |
| 24 | + end |
| 25 | + |
19 | 26 | it "includes pack generation function" do |
20 | 27 | script_content = File.read(script_path) |
21 | 28 | expect(script_content).to include("def generate_packs") |
|
42 | 49 | end |
43 | 50 |
|
44 | 51 | it "with Overmind installed, uses Overmind" do |
| 52 | + setup_script_execution |
45 | 53 | allow(IO).to receive(:popen).with("overmind -v").and_return("Some truthy result") |
46 | | - |
47 | | - expect_any_instance_of(Kernel).to receive(:system).with("bundle exec rake react_on_rails:generate_packs").and_return(true) |
48 | | - expect_any_instance_of(Kernel).to receive(:system).with("overmind start -f Procfile.dev") |
| 54 | + expect_any_instance_of(Kernel).to receive(:system).with("overmind start -f Procfile.dev").and_return(true) |
49 | 55 |
|
50 | 56 | load script_path |
51 | 57 | end |
52 | 58 |
|
53 | 59 | it "without Overmind and with Foreman installed, uses Foreman" do |
| 60 | + setup_script_execution |
54 | 61 | allow(IO).to receive(:popen).with("overmind -v").and_raise(Errno::ENOENT) |
55 | 62 | allow(IO).to receive(:popen).with("foreman -v").and_return("Some truthy result") |
56 | | - |
57 | | - expect_any_instance_of(Kernel).to receive(:system).with("bundle exec rake react_on_rails:generate_packs").and_return(true) |
58 | | - expect_any_instance_of(Kernel).to receive(:system).with("foreman start -f Procfile.dev") |
| 63 | + expect_any_instance_of(Kernel).to receive(:system).with("foreman start -f Procfile.dev").and_return(true) |
59 | 64 |
|
60 | 65 | load script_path |
61 | 66 | end |
62 | 67 |
|
63 | 68 | it "without Overmind and Foreman installed, exits with error message" do |
| 69 | + setup_script_execution |
64 | 70 | allow(IO).to receive(:popen).with("overmind -v").and_raise(Errno::ENOENT) |
65 | 71 | allow(IO).to receive(:popen).with("foreman -v").and_raise(Errno::ENOENT) |
66 | 72 | allow_any_instance_of(Kernel).to receive(:exit!) |
|
74 | 80 | end |
75 | 81 |
|
76 | 82 | it "With Overmind and without Procfile, exits with error message" do |
| 83 | + setup_script_execution |
77 | 84 | allow(IO).to receive(:popen).with("overmind -v").and_return("Some truthy result") |
78 | | - |
79 | | - allow_any_instance_of(Kernel).to receive(:system).with("bundle exec rake react_on_rails:generate_packs").and_return(true) |
80 | 85 | allow_any_instance_of(Kernel) |
81 | 86 | .to receive(:system) |
82 | 87 | .with("overmind start -f Procfile.dev") |
|
0 commit comments