|
19 | 19 |
|
20 | 20 | describe ".installed?" do
|
21 | 21 | it "returns true when process is available in current context" do
|
22 |
| - expect(Timeout).to receive(:timeout).with(5).and_yield |
| 22 | + expect(Timeout).to receive(:timeout).with(described_class::VERSION_CHECK_TIMEOUT).and_yield |
23 | 23 | expect_any_instance_of(Kernel).to receive(:system)
|
24 | 24 | .with("overmind", "--version", out: File::NULL, err: File::NULL).and_return(true)
|
25 | 25 | expect(described_class).to be_installed("overmind")
|
26 | 26 | end
|
27 | 27 |
|
28 | 28 | it "returns false when process is not available in current context" do
|
29 |
| - expect(Timeout).to receive(:timeout).with(5).and_raise(Errno::ENOENT) |
| 29 | + expect(Timeout).to receive(:timeout).with(described_class::VERSION_CHECK_TIMEOUT).and_raise(Errno::ENOENT) |
30 | 30 | expect(described_class.installed?("nonexistent")).to be false
|
31 | 31 | end
|
32 | 32 |
|
33 | 33 | it "returns false when all version flags fail" do
|
34 |
| - expect(Timeout).to receive(:timeout).with(5).exactly(3).times.and_yield |
| 34 | + expect(Timeout).to receive(:timeout).with(described_class::VERSION_CHECK_TIMEOUT).exactly(3).times.and_yield |
35 | 35 | expect_any_instance_of(Kernel).to receive(:system)
|
36 | 36 | .with("failing_process", "--version", out: File::NULL, err: File::NULL).and_return(false)
|
37 | 37 | expect_any_instance_of(Kernel).to receive(:system)
|
|
42 | 42 | end
|
43 | 43 |
|
44 | 44 | it "returns true when second version flag succeeds" do
|
45 |
| - expect(Timeout).to receive(:timeout).with(5).twice.and_yield |
| 45 | + expect(Timeout).to receive(:timeout).with(described_class::VERSION_CHECK_TIMEOUT).twice.and_yield |
46 | 46 | expect_any_instance_of(Kernel).to receive(:system)
|
47 | 47 | .with("foreman", "--version", out: File::NULL, err: File::NULL).and_return(false)
|
48 | 48 | expect_any_instance_of(Kernel).to receive(:system)
|
|
51 | 51 | end
|
52 | 52 |
|
53 | 53 | it "returns false when version check times out" do
|
54 |
| - expect(Timeout).to receive(:timeout).with(5).and_raise(Timeout::Error) |
| 54 | + expect(Timeout).to receive(:timeout).with(described_class::VERSION_CHECK_TIMEOUT).and_raise(Timeout::Error) |
55 | 55 | expect(described_class.installed?("hanging_process")).to be false
|
56 | 56 | end
|
57 | 57 | end
|
|
158 | 158 | describe ".process_available_in_system?" do
|
159 | 159 | it "checks process availability outside bundle context with version flags" do
|
160 | 160 | expect(described_class).to receive(:with_unbundled_context).and_yield
|
161 |
| - expect(Timeout).to receive(:timeout).with(5).and_yield |
| 161 | + expect(Timeout).to receive(:timeout).with(described_class::VERSION_CHECK_TIMEOUT).and_yield |
162 | 162 | expect_any_instance_of(Kernel).to receive(:system)
|
163 | 163 | .with("foreman", "--version", out: File::NULL, err: File::NULL).and_return(true)
|
164 | 164 |
|
|
173 | 173 |
|
174 | 174 | it "tries multiple version flags before failing" do
|
175 | 175 | expect(described_class).to receive(:with_unbundled_context).and_yield
|
176 |
| - expect(Timeout).to receive(:timeout).with(5).twice.and_yield |
| 176 | + expect(Timeout).to receive(:timeout).with(described_class::VERSION_CHECK_TIMEOUT).twice.and_yield |
177 | 177 | expect_any_instance_of(Kernel).to receive(:system)
|
178 | 178 | .with("foreman", "--version", out: File::NULL, err: File::NULL).and_return(false)
|
179 | 179 | expect_any_instance_of(Kernel).to receive(:system)
|
|
184 | 184 |
|
185 | 185 | it "returns false when version check times out in system context" do
|
186 | 186 | expect(described_class).to receive(:with_unbundled_context).and_yield
|
187 |
| - expect(Timeout).to receive(:timeout).with(5).and_raise(Timeout::Error) |
| 187 | + expect(Timeout).to receive(:timeout).with(described_class::VERSION_CHECK_TIMEOUT).and_raise(Timeout::Error) |
188 | 188 |
|
189 | 189 | expect(described_class.send(:process_available_in_system?, "hanging_process")).to be false
|
190 | 190 | end
|
|
0 commit comments