|
61 | 61 |
|
62 | 62 | subject.get('/events') |
63 | 63 | end |
| 64 | + |
| 65 | + it 'should raise an error when the request fails' do |
| 66 | + stub_request(:get, 'https://endpoint.test.local/events') |
| 67 | + .to_return(status: 500) |
| 68 | + |
| 69 | + expect { subject.get('/events') }.to raise_error(Userlist::RequestError) |
| 70 | + end |
| 71 | + |
| 72 | + it 'should raise a timeout error when the request times out' do |
| 73 | + stub_request(:get, 'https://endpoint.test.local/events') |
| 74 | + .to_timeout |
| 75 | + |
| 76 | + expect { subject.get('/events') }.to raise_error(Userlist::TimeoutError) |
| 77 | + end |
64 | 78 | end |
65 | 79 |
|
66 | 80 | describe '#post' do |
|
80 | 94 |
|
81 | 95 | subject.post('/events', payload) |
82 | 96 | end |
| 97 | + |
| 98 | + it 'should raise an error when the request fails' do |
| 99 | + stub_request(:post, 'https://endpoint.test.local/events') |
| 100 | + .to_return(status: 500) |
| 101 | + |
| 102 | + expect { subject.post('/events') }.to raise_error(Userlist::RequestError) |
| 103 | + end |
| 104 | + |
| 105 | + it 'should raise a timeout error when the request times out' do |
| 106 | + stub_request(:post, 'https://endpoint.test.local/events') |
| 107 | + .to_timeout |
| 108 | + |
| 109 | + expect { subject.post('/events') }.to raise_error(Userlist::TimeoutError) |
| 110 | + end |
83 | 111 | end |
84 | 112 |
|
85 | 113 | describe '#put' do |
|
99 | 127 |
|
100 | 128 | subject.put('/events', payload) |
101 | 129 | end |
| 130 | + |
| 131 | + it 'should raise an error when the request fails' do |
| 132 | + stub_request(:put, 'https://endpoint.test.local/events') |
| 133 | + .to_return(status: 500) |
| 134 | + |
| 135 | + expect { subject.put('/events') }.to raise_error(Userlist::RequestError) |
| 136 | + end |
| 137 | + |
| 138 | + it 'should raise a timeout error when the request times out' do |
| 139 | + stub_request(:put, 'https://endpoint.test.local/events') |
| 140 | + .to_timeout |
| 141 | + |
| 142 | + expect { subject.put('/events') }.to raise_error(Userlist::TimeoutError) |
| 143 | + end |
102 | 144 | end |
103 | 145 |
|
104 | 146 | describe '#delete' do |
|
118 | 160 |
|
119 | 161 | subject.delete('/events', payload) |
120 | 162 | end |
| 163 | + |
| 164 | + it 'should raise an error when the request fails' do |
| 165 | + stub_request(:delete, 'https://endpoint.test.local/events') |
| 166 | + .to_return(status: 500) |
| 167 | + |
| 168 | + expect { subject.delete('/events') }.to raise_error(Userlist::RequestError) |
| 169 | + end |
| 170 | + |
| 171 | + it 'should raise a timeout error when the request times out' do |
| 172 | + stub_request(:delete, 'https://endpoint.test.local/events') |
| 173 | + .to_timeout |
| 174 | + |
| 175 | + expect { subject.delete('/events') }.to raise_error(Userlist::TimeoutError) |
| 176 | + end |
121 | 177 | end |
122 | 178 | end |
0 commit comments