|
71 | 71 | end |
72 | 72 |
|
73 | 73 | it "uses foreman when overmind not available and foreman is available" do |
| 74 | + expect(described_class).to receive(:run_process_if_available) |
| 75 | + .with("overmind", ["start", "-f", "Procfile.dev"]).and_return(nil) |
| 76 | + expect(described_class).to receive(:run_process_if_available) |
| 77 | + .with("foreman", ["start", "-f", "Procfile.dev"]).and_return(true) |
| 78 | + |
| 79 | + described_class.run_with_process_manager("Procfile.dev") |
| 80 | + end |
| 81 | + |
| 82 | + it "exits silently when overmind is installed but exits with error (foreman not found)" do |
| 83 | + expect(described_class).to receive(:run_process_if_available) |
| 84 | + .with("overmind", ["start", "-f", "Procfile.dev"]).and_return(false) |
| 85 | + expect(described_class).to receive(:run_process_if_available) |
| 86 | + .with("foreman", ["start", "-f", "Procfile.dev"]).and_return(nil) |
| 87 | + expect(described_class).not_to receive(:show_process_manager_installation_help) |
| 88 | + expect_any_instance_of(Kernel).to receive(:exit).with(1).and_raise(SystemExit) |
| 89 | + |
| 90 | + expect { described_class.run_with_process_manager("Procfile.dev") }.to raise_error(SystemExit) |
| 91 | + end |
| 92 | + |
| 93 | + it "exits silently when overmind fails but foreman succeeds" do |
74 | 94 | expect(described_class).to receive(:run_process_if_available) |
75 | 95 | .with("overmind", ["start", "-f", "Procfile.dev"]).and_return(false) |
76 | 96 | expect(described_class).to receive(:run_process_if_available) |
77 | 97 | .with("foreman", ["start", "-f", "Procfile.dev"]).and_return(true) |
| 98 | + expect(described_class).not_to receive(:show_process_manager_installation_help) |
| 99 | + expect_any_instance_of(Kernel).not_to receive(:exit) |
78 | 100 |
|
79 | 101 | described_class.run_with_process_manager("Procfile.dev") |
80 | 102 | end |
81 | 103 |
|
82 | | - it "exits with error when no process manager available" do |
| 104 | + it "exits silently when overmind fails and foreman also fails" do |
83 | 105 | expect(described_class).to receive(:run_process_if_available) |
84 | 106 | .with("overmind", ["start", "-f", "Procfile.dev"]).and_return(false) |
85 | 107 | expect(described_class).to receive(:run_process_if_available) |
86 | 108 | .with("foreman", ["start", "-f", "Procfile.dev"]).and_return(false) |
| 109 | + expect(described_class).not_to receive(:show_process_manager_installation_help) |
| 110 | + expect_any_instance_of(Kernel).to receive(:exit).with(1).and_raise(SystemExit) |
| 111 | + |
| 112 | + expect { described_class.run_with_process_manager("Procfile.dev") }.to raise_error(SystemExit) |
| 113 | + end |
| 114 | + |
| 115 | + it "exits silently when overmind not found but foreman exits with error" do |
| 116 | + expect(described_class).to receive(:run_process_if_available) |
| 117 | + .with("overmind", ["start", "-f", "Procfile.dev"]).and_return(nil) |
| 118 | + expect(described_class).to receive(:run_process_if_available) |
| 119 | + .with("foreman", ["start", "-f", "Procfile.dev"]).and_return(false) |
| 120 | + expect(described_class).not_to receive(:show_process_manager_installation_help) |
| 121 | + expect_any_instance_of(Kernel).to receive(:exit).with(1).and_raise(SystemExit) |
| 122 | + |
| 123 | + expect { described_class.run_with_process_manager("Procfile.dev") }.to raise_error(SystemExit) |
| 124 | + end |
| 125 | + |
| 126 | + it "exits with error when no process manager available" do |
| 127 | + expect(described_class).to receive(:run_process_if_available) |
| 128 | + .with("overmind", ["start", "-f", "Procfile.dev"]).and_return(nil) |
| 129 | + expect(described_class).to receive(:run_process_if_available) |
| 130 | + .with("foreman", ["start", "-f", "Procfile.dev"]).and_return(nil) |
87 | 131 | expect(described_class).to receive(:show_process_manager_installation_help) |
88 | 132 | expect_any_instance_of(Kernel).to receive(:exit).with(1) |
89 | 133 |
|
|
117 | 161 | expect(result).to be true |
118 | 162 | end |
119 | 163 |
|
120 | | - it "returns false when process not available anywhere" do |
| 164 | + it "returns nil when process not available anywhere" do |
121 | 165 | allow(described_class).to receive(:installed?).with("nonexistent").and_return(false) |
122 | 166 | allow(described_class).to receive(:process_available_in_system?).with("nonexistent").and_return(false) |
123 | 167 |
|
124 | 168 | result = described_class.send(:run_process_if_available, "nonexistent", ["start"]) |
125 | | - expect(result).to be false |
| 169 | + expect(result).to be_nil |
126 | 170 | end |
127 | 171 | end |
128 | 172 |
|
|
0 commit comments