Sha256: d0607bc6e89811cfa2c205fff2c2fe75f35424a99b0775898c8033f3ae04dd01

Contents?: true

Size: 1.64 KB

Versions: 14

Compression:

Stored size: 1.64 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Repos, '#contributors' do
  let(:user) { 'peter-murach' }
  let(:repo) { 'github' }

  after { reset_authentication_for subject }

  let(:request_path) { "/repos/#{user}/#{repo}/contributors" }

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

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

    it "should raise error when no user/repo parameters" do
      expect { subject.contributors }.to raise_error(ArgumentError)
    end

    it "should raise error when no repository" do
      expect { subject.contributors user }.to raise_error(ArgumentError)
    end

    it 'filters out unkown parameters' do
      subject.contributors user, repo, :unknown => true
      a_get(request_path).with({}).should have_been_made
    end

    it "should find resources" do
      subject.contributors user, repo
      a_get(request_path).should have_been_made
    end

    it_should_behave_like 'an array of resources' do
      let(:requestable) { subject.contributors user, repo }
    end

    it "should get branch information" do
      contributors = subject.contributors user, repo
      contributors.first.login.should == 'octocat'
    end

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

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

end # contributors

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
github_api-0.11.3 spec/github/repos/contributors_spec.rb
github_api-0.11.2 spec/github/repos/contributors_spec.rb
github_api-0.11.1 spec/github/repos/contributors_spec.rb
github_api-0.11.0 spec/github/repos/contributors_spec.rb
github_api-0.10.2 spec/github/repos/contributors_spec.rb
github_api-0.10.1 spec/github/repos/contributors_spec.rb
github_api-0.10.0 spec/github/repos/contributors_spec.rb
github_api-0.9.7 spec/github/repos/contributors_spec.rb
github_api-0.9.6 spec/github/repos/contributors_spec.rb
github_api-0.9.5 spec/github/repos/contributors_spec.rb
github_api-0.9.4 spec/github/repos/contributors_spec.rb
github_api-0.9.3 spec/github/repos/contributors_spec.rb
github_api-0.9.2 spec/github/repos/contributors_spec.rb
github_api-0.9.1 spec/github/repos/contributors_spec.rb