Sha256: 5ae04b179191d939d0ded9e867db1202bb54921518d763d22a18f1a21619eba3

Contents?: true

Size: 750 Bytes

Versions: 2

Compression:

Stored size: 750 Bytes

Contents

require 'helper'

describe Faraday::Response do
  before do
    @client = Disqussion::Client.users
  end

  {
    400 => Disqussion::BadRequest,
    401 => Disqussion::Unauthorized,
    403 => Disqussion::Forbidden,
    404 => Disqussion::NotFound,
    500 => Disqussion::InternalServerError,
  }.each do |status, exception|
    context "when HTTP status is #{status}" do

      before do
        stub_get('users/details.json').
          to_return(:status => status, :body => fixture("faraday/error2.json"), :headers => {:content_type => "application/json; charset=utf-8"})
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
disqussion-0.0.5 spec/faraday/response_spec.rb
disqussion-0.0.4 spec/faraday/response_spec.rb