Sha256: c9c8dc7b450616275c2a64a1d1a3645c0740db84f9908ee2cd8a4ea7e92e2c4a

Contents?: true

Size: 1.16 KB

Versions: 36

Compression:

Stored size: 1.16 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Error::ServiceError do
  let(:user) { 'peter-murach' }
  let(:repo) { 'github' }

  def test_request(body='')
    stub_get("/repos/#{user}/#{repo}/branches").
      to_return(:body => body, :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
  end

  it "handles empty message" do
    test_request
    expect {
      Github.repos.branches user, repo
    }.to raise_error(Github::Error::NotFound)
  end

  it "handles error message" do
    test_request :error => 'not found'
    expect {
      Github.repos.branches user, repo
    }.to raise_error(Github::Error::NotFound, /not found/)
  end

  it "handles nested errors" do
    test_request :errors => { :message => 'key is already in use' }
    expect {
      Github.repos.branches user, repo
    }.to raise_error(Github::Error::NotFound, /key is already in use/)
  end

  it 'decodes message' do
    test_request MultiJson.dump(:errors => { :message => 'key is already in use' })
    expect {
      Github.repos.branches user, repo
    }.to raise_error(Github::Error::NotFound, /key is already in use/)
  end


end # Github::Error::ServiceError

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
github_api-0.12.3 spec/github/error/service_error_spec.rb
github_api-0.12.2 spec/github/error/service_error_spec.rb
github_api-0.12.1 spec/github/error/service_error_spec.rb
github_api-0.12.0 spec/github/error/service_error_spec.rb
github_api-0.11.3 spec/github/error/service_error_spec.rb
github_api-0.11.2 spec/github/error/service_error_spec.rb
github_api-0.11.1 spec/github/error/service_error_spec.rb
github_api-0.11.0 spec/github/error/service_error_spec.rb
github_api-0.10.2 spec/github/error/service_error_spec.rb
github_api-0.10.1 spec/github/error/service_error_spec.rb
github_api-0.10.0 spec/github/error/service_error_spec.rb
github_api-0.9.7 spec/github/error/service_error_spec.rb
github_api-0.9.6 spec/github/error/service_error_spec.rb
github_api-0.9.5 spec/github/error/service_error_spec.rb
github_api-0.9.4 spec/github/error/service_error_spec.rb
github_api-0.9.3 spec/github/error/service_error_spec.rb
github_api-0.9.2 spec/github/error/service_error_spec.rb
github_api-0.9.1 spec/github/error/service_error_spec.rb
github_api-0.9.0 spec/github/error/service_error_spec.rb
github_api-0.8.11 spec/github/error/service_error_spec.rb