diff options
author | Stan Hu <stanhu@gmail.com> | 2018-07-28 00:29:05 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-28 00:29:05 +0300 |
commit | 57d1b60f61a790c034b8d43ce2358371464d2d67 (patch) | |
tree | c1e625ab9ec32a89f51ca966c1b3245d3db1a1b6 /spec/lib/bitbucket_server | |
parent | 450030e9029f5de6fcfb850e5940838c2a76c81e (diff) |
Handle invalid JSON from server
Diffstat (limited to 'spec/lib/bitbucket_server')
-rw-r--r-- | spec/lib/bitbucket_server/connection_spec.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/lib/bitbucket_server/connection_spec.rb b/spec/lib/bitbucket_server/connection_spec.rb index 33a037218a0..b5da4cb1a49 100644 --- a/spec/lib/bitbucket_server/connection_spec.rb +++ b/spec/lib/bitbucket_server/connection_spec.rb @@ -20,6 +20,12 @@ describe BitbucketServer::Connection do expect { subject.get(url) }.to raise_error(described_class::ConnectionError) end + + it 'throws an exception if the response is not JSON' do + WebMock.stub_request(:get, url).with(headers: { 'Accept' => 'application/json' }).to_return(body: 'bad data', status: 200, headers: headers) + + expect { subject.get(url) }.to raise_error(described_class::ConnectionError) + end end describe '#post' do |