Sha256: af451c832bdabe9c54292c5483be5b91c3cf3e2cf155c28a36160a7b74fff21a
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
require 'spec_helper' describe CFoundry::BaseClient do let(:base) { CFoundry::BaseClient.new("https://api.cloudfoundry.com") } describe '#request_uri' do subject { base.request_uri URI.parse(base.target + "/foo"), Net::HTTP::Get } context 'when a timeout exception occurs' do before { stub_request(:get, 'https://api.cloudfoundry.com/foo').to_raise(::Timeout::Error) } it 'raises the correct error' do expect { subject }.to raise_error CFoundry::Timeout, "GET https://api.cloudfoundry.com/foo timed out" end end context 'when an HTTPNotFound error occurs' do before { stub_request(:get, 'https://api.cloudfoundry.com/foo').to_return :status => 404, :body => "NOT FOUND" } it 'raises the correct error' do expect {subject}.to raise_error CFoundry::NotFound, "404: NOT FOUND" end end context 'when an HTTPForbidden error occurs' do before { stub_request(:get, 'https://api.cloudfoundry.com/foo').to_return :status => 403, :body => "NONE SHALL PASS" } it 'raises the correct error' do expect {subject}.to raise_error CFoundry::Denied, "403: NONE SHALL PASS" end end context "when any other type of error occurs" do before { stub_request(:get, 'https://api.cloudfoundry.com/foo').to_return :status => 411, :body => "NOT LONG ENOUGH" } it 'raises the correct error' do expect {subject}.to raise_error CFoundry::BadResponse, "411: NOT LONG ENOUGH" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cfoundry-0.4.21 | spec/cfoundry/baseclient_spec.rb |
cfoundry-0.4.19 | spec/cfoundry/baseclient_spec.rb |