-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy patherror_handler_spec.rb
53 lines (46 loc) · 1.26 KB
/
error_handler_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
RSpec.describe ThreeScaleToolbox::CLI::ErrorHandler do
include_context :temp_dir
context '#error_watchdog' do
def raise_runtime_error
raise 'some error'
end
def raise_toolbox_error
raise ThreeScaleToolbox::Error, 'some error'
end
context 'raises expected error' do
it 'error is shown on stderr' do
Dir.chdir(tmp_dir) do
expect do
subject.error_watchdog { raise_toolbox_error }
end.to output(/some error/).to_stderr
expect(File).not_to exist('crash.log')
end
end
it 'returns error' do
expect(
subject.error_watchdog { raise_toolbox_error }
).to be
end
end
context 'raises unexpected error' do
it 'crash.log is generated' do
Dir.chdir(tmp_dir) do
expect do
subject.error_watchdog { raise_runtime_error }
end.to output(/some error/).to_stderr
expect(File).to exist('crash.log')
end
end
it 'returns error' do
expect(
subject.error_watchdog { raise_runtime_error }
).to be
end
end
context 'Does not raise error' do
it 'returns true' do
expect(subject.error_watchdog {}).to be_nil
end
end
end
end