Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-28 00:29:05 +0300
committerStan Hu <stanhu@gmail.com>2018-07-28 00:29:05 +0300
commit57d1b60f61a790c034b8d43ce2358371464d2d67 (patch)
treec1e625ab9ec32a89f51ca966c1b3245d3db1a1b6 /spec/lib/bitbucket_server
parent450030e9029f5de6fcfb850e5940838c2a76c81e (diff)
Handle invalid JSON from server
Diffstat (limited to 'spec/lib/bitbucket_server')
-rw-r--r--spec/lib/bitbucket_server/connection_spec.rb6
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