|
18 | 18 | end
|
19 | 19 | end
|
20 | 20 |
|
| 21 | + context 'when option is `-l 5xx`' do |
| 22 | + it 'returns all http codes belonging to type' do |
| 23 | + expect do |
| 24 | + options = new_input_parser.parse(['-l', '5xx']) |
| 25 | + expect(options).to be_an_instance_of(OpenStruct) |
| 26 | + expect(options.verbose).to be nil |
| 27 | + expect(options.status_type).to eq('5xx') |
| 28 | + end.to terminate.with_code(0) |
| 29 | + end |
| 30 | + end |
| 31 | + |
| 32 | + context 'when option is `-l 5xc`' do |
| 33 | + it 'should exit with status 1' do |
| 34 | + expect do |
| 35 | + options = new_input_parser.parse(['-l', '5xc']) |
| 36 | + expect(options).to be_an_instance_of(OpenStruct) |
| 37 | + expect(options.verbose).to be nil |
| 38 | + expect(options.status_type).to eq('5xx') |
| 39 | + end.to terminate.with_code(1) |
| 40 | + end |
| 41 | + end |
| 42 | + |
| 43 | + context 'list all http codes' do |
| 44 | + it 'returns all http codes' do |
| 45 | + expect do |
| 46 | + options = new_input_parser.parse(['-l']) |
| 47 | + expect(options).to be_an_instance_of(OpenStruct) |
| 48 | + expect(options.status_type).to be nil |
| 49 | + end.to terminate.with_code(0) |
| 50 | + end |
| 51 | + end |
| 52 | + |
| 53 | + context 'when option is --help' do |
| 54 | + it 'displays help message' do |
| 55 | + expect do |
| 56 | + options = new_input_parser.parse(['--help']) |
| 57 | + expect(options).to be_an_instance_of(OpenStruct) |
| 58 | + end.to terminate.with_code(0) |
| 59 | + end |
| 60 | + end |
| 61 | + |
| 62 | + context 'when option is --version' do |
| 63 | + it 'displays version' do |
| 64 | + expect do |
| 65 | + options = new_input_parser.parse(['--version']) |
| 66 | + expect(options).to be_an_instance_of(OpenStruct) |
| 67 | + end.to terminate.with_code(0) |
| 68 | + end |
| 69 | + end |
| 70 | + |
21 | 71 | context 'Invalid requests' do
|
22 | 72 | let(:options) { new_input_parser.parse(['-f']) }
|
23 | 73 |
|
24 |
| - it 'raises an error' do |
25 |
| - expect { options }.to raise_error |
| 74 | + it 'exit with status 1' do |
| 75 | + expect { options }.to terminate.with_code(1) |
26 | 76 | end
|
27 | 77 | end
|
28 | 78 | end
|
|
0 commit comments