Sha256: 751b9414302a00511c98f09ef69af131ee66c72b94f6baec45339ca97f8c36f5

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Repos::Forks, '#create' do
  let(:user) { 'peter-murach' }
  let(:repo) { 'github' }
  let(:request_path) { "/repos/#{user}/#{repo}/forks" }
  let(:inputs) { {:org => 'github'} }

  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 "resouce created" do
    let(:body)   { fixture('repos/fork.json') }
    let(:status) { 202 }

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

    it "should return the resource" do
      fork = subject.create user, repo, inputs
      fork.should be_a Hashie::Mash
    end

    it "should get the fork information" do
      fork = subject.create user, repo, inputs
      fork.name.should == 'Hello-World'
    end
  end

  context "failed to create resource" do
    let(:body)   { "" }
    let(:status) { 404 }

    it "should faile to retrieve resource" do
      expect {
        subject.create user, repo, inputs
      }.to raise_error(Github::Error::NotFound)
    end
  end
end # create

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
github_api-0.8.0 spec/github/repos/forks/create_spec.rb
github_api-0.7.2 spec/github/repos/forks/create_spec.rb
github_api-0.7.1 spec/github/repos/forks/create_spec.rb