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

- old
+ new

@@ -11,12 +11,15 @@ stub_request( :put, 'https://example.cybozu.com/k/v1/space/thread.json' ) .with(body: request_body) - .to_return(body: '{}', status: 200, - headers: { 'Content-type' => 'application/json' }) + .to_return( + body: '{}', + status: 200, + headers: { 'Content-type' => 'application/json' } + ) end subject { target.update(id, name: name, body: body) } let(:id) { 1 } @@ -46,8 +49,29 @@ ] end with_them do it { expect(subject).to be_truthy } + end + + context 'fail to request' do + before(:each) do + stub_request( + :put, + 'https://example.cybozu.com/k/v1/space/thread.json' + ) + .with(body: request_body) + .to_return( + body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}', + status: 500, + headers: { 'Content-Type' => 'application/json' } + ) + end + + let(:name) { 'example thread' } + let(:body) { '<b>awesome thread!</b>' } + let(:request_body) { '{"id":1,"name":"example thread","body":"<b>awesome thread!</b>"}' } + + it { expect { subject }.to raise_error Kintone::KintoneError } end end end