Sha256: 6f74071c5e1e91c23ac5a83881dc72248213a06226462a6862208b227a5a84c0

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 Bytes

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe Faraday::Response do
  before do
    @client = Thounds::Client.new
  end

  {
    400 => Thounds::BadRequest,
    401 => Thounds::Unauthorized,
    403 => Thounds::Forbidden,
    404 => Thounds::NotFound,
    406 => Thounds::NotAcceptable,
    500 => Thounds::InternalServerError,
    502 => Thounds::BadGateway,
    503 => Thounds::ServiceUnavailable,
  }.each do |status, exception|
    context "when HTTP status is #{status}" do

      before do
        stub_get('users/171').to_return(:status => status)
      end

      it "should raise #{exception.name} error" do
        lambda do
          @client.users(171) {|user| user}
        end.should raise_error(exception)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thounds-0.0.2 spec/faraday/response_spec.rb
thounds-0.0.1 spec/faraday/response_spec.rb