spec/kintone/command/bulk_request_spec.rb in kintone-0.1.4 vs spec/kintone/command/bulk_request_spec.rb in kintone-0.1.5

- old
+ new

@@ -11,12 +11,15 @@ stub_request( :post, 'https://example.cybozu.com/k/v1/bulkRequest.json' ) .with(body: { requests: requests }.to_json) - .to_return(body: { 'results' => results }.to_json, status: 200, - headers: { 'Content-type' => 'application/json' }) + .to_return( + body: { 'results' => results }.to_json, + status: 200, + headers: { 'Content-type' => 'application/json' } + ) end subject { target.request(requests) } let(:requests) do @@ -66,7 +69,24 @@ {} ] end it { is_expected.to eq results } + + context 'fail to request' do + before(:each) do + stub_request( + :post, + 'https://example.cybozu.com/k/v1/bulkRequest.json' + ) + .with(body: { requests: requests }.to_json) + .to_return( + body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}', + status: 500, + headers: { 'Content-Type' => 'application/json' } + ) + end + + it { expect { subject }.to raise_error Kintone::KintoneError } + end end end