Sha256: 57197153fb044a57444f19a0f6e3cadb1a57fca01692130d1511d031e0b6ad35
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
require 'helper' describe 'Lelylan Error' do let(:lelylan) do a_client end describe 'Unauthorized Access' do before do stub_get('/devices/1').to_return(status: 401, body: fixture('errors/401.json')) end it 'raises a Lelylan::Unauthorized' do expect{ lelylan.device('1') }.to raise_error(Lelylan::Unauthorized, 'Token not valid') end end describe 'Not Found' do before do stub_get('/devices/1').to_return(status: 404, body: fixture('errors/404.json')) end it 'raises a Lelylan::NotFound' do expect{ lelylan.device('1') }.to raise_error(Lelylan::NotFound, 'Resource not found') end end describe 'Unprocessable Entity' do before do stub_get('/devices/1').to_return(status: 422, body: fixture('errors/422.json')) end it 'raises a Lelylan::UnprocessableEntity' do expect{ lelylan.device('1') }.to raise_error(Lelylan::UnprocessableEntity, 'Name can\'t be blank.') end end describe 'Internal Server Error' do before do stub_get('/devices/1').to_return(status: 500, body: 'Internal Error Server') end it 'raises a Lelylan::InternalServerError' do expect{ lelylan.device('1') }.to raise_error(Lelylan::InternalServerError, 'Internal Error Server') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lelylan-rb-0.1.0 | spec/lelylan/error_spec.rb |
lelylan-rb-0.0.5 | spec/lelylan/error_spec.rb |
lelylan-rb-0.0.4 | spec/lelylan/error_spec.rb |