Sha256: d3409b36cacabe5cd699c838aa6f8400dfb0d514e590e1eb97f7f6462d0ec0f8

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Client::Authorizations, '#update' do
  let(:basic_auth) { 'login:password' }
  let(:request_path) { "/authorizations/#{authorization_id}" }
  let(:host) { "https://#{basic_auth}@api.github.com" }
  let(:authorization_id) { 1 }
  let(:inputs) { { :add_scopes => ['repo'] } }

  before {
    stub_patch(request_path, host).to_return(:body => body, :status => status,
      :headers => {:content_type => "application/json; charset=utf-8"})
  }

  before { subject.basic_auth = basic_auth }

  after { reset_authentication_for(subject) }

  context "resouce updated" do
    let(:body) { fixture('auths/authorization.json') }
    let(:status) { 201 }

    it "should fail to get resource without basic authentication" do
      reset_authentication_for subject
      expect { subject.update }.to raise_error(ArgumentError)
    end

    it "should update resource successfully" do
      subject.update authorization_id, inputs
      a_patch(request_path, host).with(inputs).should have_been_made
    end

    it "should return the resource" do
      authorization = subject.update authorization_id, inputs
      authorization.should be_a Github::ResponseWrapper
    end

    it "should get the authorization information" do
      authorization = subject.update authorization_id, inputs
      authorization.token.should == 'abc123'
    end
  end

  it_should_behave_like 'request failure' do
    let(:requestable) { subject.update authorization_id, inputs }
  end
end # update

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.12.3 spec/github/client/authorizations/update_spec.rb
github_api-0.12.2 spec/github/client/authorizations/update_spec.rb
github_api-0.12.1 spec/github/client/authorizations/update_spec.rb
github_api-0.12.0 spec/github/client/authorizations/update_spec.rb