Sha256: 459afd7b01638806a25eb28832d031452fabfb83f04732ad034258a9e84f169d

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# -*- encoding: utf-8 -*-
require 'spec_helper'

describe Faraday::Response do
  before do
    @client = Reshape::Client.new({
      consumer_token: ENV['SHAPEWAYS_CONSUMER_TOKEN'], 
      consumer_secret: ENV['SHAPEWAYS_CONSUMER_SECRET'], 
      oauth_token: ENV['SHAPEWAYS_OAUTH_TOKEN'], 
      oauth_secret: ENV['SHAPEWAYS_OAUTH_SECRET'], 
      proxy: 'http://localhost:8888'
    })
  end

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

      before do
        stub_get('orders/cart').to_return(:status => status)
      end

      it "should raise #{exception.name} error" do
        lambda do
          @client.cart
        end.should raise_error(exception)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reshape-0.2 spec/faraday/response_spec.rb
reshape-0.1.1 spec/faraday/response_spec.rb
reshape-0.1 spec/faraday/response_spec.rb