Sha256: 68b3a213f301a8ab03c3997366768ae42829b2f0c21355801e7aa5784e110422

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe BitBucket::Response::RaiseError do
  describe '.on_complete' do
    before do
      @raise_error = BitBucket::Response::RaiseError.new
    end

    it 'raises a BadRequest error on 400 status code' do
      expect { @raise_error.on_complete(status: 400) }.to raise_error BitBucket::Error::BadRequest
    end

    it 'raises an Unauthorized error on 401 status code' do
      expect { @raise_error.on_complete(status: 401) }.to raise_error BitBucket::Error::Unauthorized
    end

    it 'raises a Forbidden error on 403 status code' do
      expect { @raise_error.on_complete(status: 403) }.to raise_error BitBucket::Error::Forbidden
    end

    it 'raises a NotFound error on 404 status code' do
      expect { @raise_error.on_complete(status: 404) }.to raise_error BitBucket::Error::NotFound
    end

    it 'raises an UnprocessableEntity error on 422 status code' do
      expect { @raise_error.on_complete(status: 422) }.to raise_error BitBucket::Error::UnprocessableEntity
    end

    it 'raises an InternalServerError error on 500 status code' do
      expect { @raise_error.on_complete(status: 500) }.to raise_error BitBucket::Error::InternalServerError
    end

    it 'raises a ServiceUnavailable error on 503 status code' do
      expect { @raise_error.on_complete(status: 503) }.to raise_error BitBucket::Error::ServiceUnavailable
    end

    it 'raises a ServiceError when another status code' do
      expect { @raise_error.on_complete(status: 501) }.to raise_error BitBucket::Error::ServiceError
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitbuckets-0.2.0 spec/bitbucket_rest_api/response/raise_error_spec.rb