Skip to content

Commit a53a2f9

Browse files
ihabadhamjustin808
authored andcommitted
ci: fix failures because of ARGV and exits
1 parent d770bfc commit a53a2f9

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

spec/react_on_rails/binstubs/dev_spec.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
$stdout = original_stdout
1717
end
1818

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+
1926
it "includes pack generation function" do
2027
script_content = File.read(script_path)
2128
expect(script_content).to include("def generate_packs")
@@ -42,25 +49,24 @@
4249
end
4350

4451
it "with Overmind installed, uses Overmind" do
52+
setup_script_execution
4553
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)
4955

5056
load script_path
5157
end
5258

5359
it "without Overmind and with Foreman installed, uses Foreman" do
60+
setup_script_execution
5461
allow(IO).to receive(:popen).with("overmind -v").and_raise(Errno::ENOENT)
5562
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)
5964

6065
load script_path
6166
end
6267

6368
it "without Overmind and Foreman installed, exits with error message" do
69+
setup_script_execution
6470
allow(IO).to receive(:popen).with("overmind -v").and_raise(Errno::ENOENT)
6571
allow(IO).to receive(:popen).with("foreman -v").and_raise(Errno::ENOENT)
6672
allow_any_instance_of(Kernel).to receive(:exit!)
@@ -74,9 +80,8 @@
7480
end
7581

7682
it "With Overmind and without Procfile, exits with error message" do
83+
setup_script_execution
7784
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)
8085
allow_any_instance_of(Kernel)
8186
.to receive(:system)
8287
.with("overmind start -f Procfile.dev")

0 commit comments

Comments
 (0)