Sha256: 41f2d5741cd3e55d9a70006ece94b4f4901e514b82f50e0af40e58dc7a90e49e

Contents?: true

Size: 839 Bytes

Versions: 6

Compression:

Stored size: 839 Bytes

Contents

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

describe Faraday::Response do

  let(:client) do
    Lelylan::Client.new
  end

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

    context "when HTTP status is #{status}" do

      before do
        stub_get('http://api.lelylan.com/devices').
          to_return(:status => status)
      end

      it "should raise #{exception.name} error" do
        expect do
          client.devices
        end.to raise_error(exception)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lelylan-rb-0.1.0 spec/faraday/response_spec.rb
lelylan-rb-0.0.5 spec/faraday/response_spec.rb
lelylan-rb-0.0.4 spec/faraday/response_spec.rb
lelylan-rb-0.0.3 spec/faraday/response_spec.rb
lelylan-rb-0.0.2 spec/faraday/response_spec.rb
lelylan-rb-0.0.1 spec/faraday/response_spec.rb