Sha256: 480eb750e2bc42670a3419ccce673f2a375f123c30c4a1aa5c4c8a1f80d98a6a

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

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

  after { reset_authentication_for(subject) }


  context "resource found" do
    let(:body)   { fixture('repos/forks.json') }
    let(:status) { 200 }

    it { should respond_to :all }

    it "should fail to get resource without username" do
      expect { subject.list }.to raise_error(ArgumentError)
    end

    it "should get the resources" do
      subject.list user, repo
      a_get(request_path).should have_been_made
    end

    it "should return array of resources" do
      forks = subject.list user, repo
      forks.should be_an Array
      forks.should have(1).items
    end

    it "should be a mash type" do
      forks = subject.list user, repo
      forks.first.should be_a Hashie::Mash
    end

    it "should get fork information" do
      forks = subject.list user, repo
      forks.first.name.should == 'Hello-World'
    end

    it "should yield to a block" do
      subject.should_receive(:list).with(user, repo).and_yield('web')
      subject.list(user, repo) { |param| 'web' }
    end
  end

  context "resource not found" do
    let(:body)   { "" }
    let(:status) { [404, "Not Found"] }

    it "should return 404 with a message 'Not Found'" do
      expect {
        subject.list user, repo
      }.to raise_error(Github::Error::NotFound)
    end
  end
end # list

Version data entries

3 entries across 3 versions & 1 rubygems

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