Sha256: 84f19d2bd40836e1ec93073ced0b7e325285ec06b0899bcb1a576c511194051a

Contents?: true

Size: 1.42 KB

Versions: 25

Compression:

Stored size: 1.42 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Repos::Keys, '#create' do
  let(:user) { 'peter-murach' }
  let(:repo) { 'github' }
  let(:request_path) { "/repos/#{user}/#{repo}/keys" }
  let(:inputs) { {:title => "octocat@octomac", :key => "ssh-rsa AAA..." } }

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

  after { reset_authentication_for(subject) }

  context "resource created" do
    let(:body) { fixture("repos/key.json") }
    let(:status) { 201 }

    it "should fail to create resource if 'title' input is missing" do
      expect {
        subject.create user, repo, :key => 'ssh-rsa AAA...'
      }.to raise_error(Github::Error::RequiredParams)
    end

    it "should fail to create resource if 'key' input is missing" do
      expect {
        subject.create user, repo, :title => 'octocat@octomac'
      }.to raise_error(Github::Error::RequiredParams)
    end

    it "should create the resource" do
      subject.create user, repo, inputs
      a_post(request_path).with(inputs).should have_been_made
    end

    it "should get the key information back" do
      key = subject.create user, repo, inputs
      key.title.should == 'octocat@octomac'
    end
  end

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

end # create

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
github_api-0.11.3 spec/github/repos/keys/create_spec.rb
github_api-0.11.2 spec/github/repos/keys/create_spec.rb
github_api-0.11.1 spec/github/repos/keys/create_spec.rb
github_api-0.11.0 spec/github/repos/keys/create_spec.rb
github_api-0.10.2 spec/github/repos/keys/create_spec.rb
github_api-0.10.1 spec/github/repos/keys/create_spec.rb
github_api-0.10.0 spec/github/repos/keys/create_spec.rb
github_api-0.9.7 spec/github/repos/keys/create_spec.rb
github_api-0.9.6 spec/github/repos/keys/create_spec.rb
github_api-0.9.5 spec/github/repos/keys/create_spec.rb
github_api-0.9.4 spec/github/repos/keys/create_spec.rb
github_api-0.9.3 spec/github/repos/keys/create_spec.rb
github_api-0.9.2 spec/github/repos/keys/create_spec.rb
github_api-0.9.1 spec/github/repos/keys/create_spec.rb
github_api-0.9.0 spec/github/repos/keys/create_spec.rb
github_api-0.8.11 spec/github/repos/keys/create_spec.rb
github_api-0.8.10 spec/github/repos/keys/create_spec.rb
github_api-0.8.9 spec/github/repos/keys/create_spec.rb
github_api-0.8.8 spec/github/repos/keys/create_spec.rb
github_api-0.8.7 spec/github/repos/keys/create_spec.rb