Sha256: 925d697a47c5278c3f49d9b336088565408bd82139b73296da849052f9a58d11

Contents?: true

Size: 1.36 KB

Versions: 14

Compression:

Stored size: 1.36 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  before {
    stub_post(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 created" 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.create }.to raise_error(ArgumentError)
    end

    it "should create resource successfully" do
      subject.create inputs
      a_post(request_path, host).with(inputs).should have_been_made
    end

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

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

  it_should_behave_like 'request failure' do
    let(:requestable) { subject.create inputs }
  end

end # create

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
github_api-0.11.2 spec/github/authorizations/create_spec.rb
github_api-0.11.1 spec/github/authorizations/create_spec.rb
github_api-0.11.0 spec/github/authorizations/create_spec.rb
github_api-0.10.2 spec/github/authorizations/create_spec.rb
github_api-0.10.1 spec/github/authorizations/create_spec.rb
github_api-0.10.0 spec/github/authorizations/create_spec.rb
github_api-0.9.7 spec/github/authorizations/create_spec.rb
github_api-0.9.6 spec/github/authorizations/create_spec.rb
github_api-0.9.5 spec/github/authorizations/create_spec.rb
github_api-0.9.4 spec/github/authorizations/create_spec.rb
github_api-0.9.3 spec/github/authorizations/create_spec.rb
github_api-0.9.2 spec/github/authorizations/create_spec.rb
github_api-0.9.1 spec/github/authorizations/create_spec.rb
github_api-0.9.0 spec/github/authorizations/create_spec.rb