Sha256: 9be0fc63ac80d4cd025b212ae7600de947c9d7240ee30a9bf5180069c5272689

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 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|
          e.should be_a_kind_of(Transifex::Error)
          e.should respond_to(:response)
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
transifex-ruby-0.0.4 spec/transifex/error_spec.rb
transifex-ruby-fork-jg-0.1.0 spec/transifex/error_spec.rb