Sha256: 25b30a537201549cec036d52973a1478991d4accd53bc801feca6bc7581505a0

Contents?: true

Size: 937 Bytes

Versions: 4

Compression:

Stored size: 937 Bytes

Contents

require 'helper'

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

      before do
        Open311.configure do |config|
          config.endpoint     = 'http://api.dc.org/open311/v2_dev/'
          config.jurisdiction = 'dc.gov'
        end
        stub_request(:get, 'http://api.dc.org/open311/v2_dev/services.xml').
          with(:query => {:jurisdiction_id => 'dc.gov'}).
          to_return(:status => status)
      end

      it "should raise #{exception.name} error" do
        lambda do
          Open311.service_list
        end.should raise_error(exception)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
open311-0.2.3 spec/faraday/response_spec.rb
open311-0.2.2 spec/faraday/response_spec.rb
open311-0.2.1 spec/faraday/response_spec.rb
open311-0.2.0 spec/faraday/response_spec.rb