Sha256: a0bc6f8130c5d2b6f8a15bfce646d25105eced4693234c2ab8f15f8dce02f373

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

require 'spec_helper'

describe Transifex::Error do
  let(:client) { Transifex::Client.new }

  {
    401 => Transifex::Unauthorized,
    403 => Transifex::Forbidden,
    404 => Transifex::NotFound,
    406 => Transifex::NotAcceptable,
    409 => Transifex::Conflict,
    415 => Transifex::UnsupportedMediaType,
    422 => Transifex::UnprocessableEntity,
  }.each do |status, exception|
    context "when HTTP response status is #{status}" do
      before do
        stub_get('/project/xyz/').to_return(status: status)
      end

      it "should raise #{exception.name} error" do
        expect {
          client.project('xyz')
        }.to raise_error(exception) { |e|
          expect(e).to be_a_kind_of(Transifex::Error)
          expect(e).to respond_to(:response)
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
transifex-ruby-0.1.0 spec/transifex/error_spec.rb
transifex-ruby-0.0.6 spec/transifex/error_spec.rb
transifex-ruby-0.0.5 spec/transifex/error_spec.rb