diff options
Diffstat (limited to 'spec/lib/bitbucket_server')
-rw-r--r-- | spec/lib/bitbucket_server/connection_spec.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/lib/bitbucket_server/connection_spec.rb b/spec/lib/bitbucket_server/connection_spec.rb index 911f6eea8bf..45affbcf4e4 100644 --- a/spec/lib/bitbucket_server/connection_spec.rb +++ b/spec/lib/bitbucket_server/connection_spec.rb @@ -4,12 +4,11 @@ describe BitbucketServer::Connection do let(:options) { { base_uri: 'https://test:7990', user: 'bitbucket', password: 'mypassword' } } let(:payload) { { 'test' => 1 } } let(:headers) { { "Content-Type" => "application/json" } } + let(:url) { 'https://test:7990/rest/api/1.0/test?something=1' } subject { described_class.new(options) } describe '#get' do - let(:url) { 'https://test:7990/rest/api/1.0/test?something=1' } - it 'returns JSON body' do WebMock.stub_request(:get, url).to_return(body: payload.to_json, status: 200, headers: headers) @@ -24,5 +23,16 @@ describe BitbucketServer::Connection do end describe '#post' do + it 'returns JSON body' do + WebMock.stub_request(:post, url).to_return(body: payload.to_json, status: 200, headers: headers) + + expect(subject.post(url, payload)).to eq(payload) + end + + it 'throws an exception if the response is not 200' do + WebMock.stub_request(:post, url).to_return(body: payload.to_json, status: 500, headers: headers) + + expect { subject.post(url, payload) }.to raise_error(described_class::ConnectionError) + end end end |