Sha256: 54c968f3448b43e689dd724701294aa7a6553b095c3307164faf33b96e9f94f5

Contents?: true

Size: 959 Bytes

Versions: 7

Compression:

Stored size: 959 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Error::ServiceError, 'parse_response' do
  let(:message) { 'Requires authentication' }
  let(:url)     { 'https://api.github.com/user/repos' }
  let(:body)    { "{\"message\":\"#{message}\"}" }
  let(:status)  { "401 Unauthorized" }
  let(:response_headers) { {"status"=>"401 Unauthorized"} }
  let(:response) {{
    body: body,
    status: status,
    response_headers: response_headers,
    url: url
  }}

  let(:object) { described_class.new(response) }

  subject { object.parse_response(response) }

  it "parses body" do
    expect(object).to receive(:parse_body).with(body)
    subject
  end

  it "parses http headers" do
    expect(object.http_headers).to eql(response_headers)
  end

  it "parses status" do
    expect(object.status).to eql(status)
  end

  it "assembles error message" do
    expect(subject).to eql(" #{url}: #{status} #{message}")
  end
end # Github::Error::ServiceError

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
github_api-0.12.3 spec/github/error/service_error/parse_response_spec.rb
github_api-0.12.2 spec/github/error/service_error/parse_response_spec.rb
github_api-0.12.1 spec/github/error/service_error/parse_response_spec.rb
github_api-0.12.0 spec/github/error/service_error/parse_response_spec.rb
github_api-0.11.3 spec/github/error/service_error/parse_response_spec.rb
github_api-0.11.2 spec/github/error/service_error/parse_response_spec.rb
github_api-0.11.1 spec/github/error/service_error/parse_response_spec.rb