Sha256: 55e6ac058c2c6fdf483af0a7c647f3a589e5f1ebe2893b94d9f2d206c6ffabb9

Contents?: true

Size: 1.36 KB

Versions: 12

Compression:

Stored size: 1.36 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Repos::Collaborators, '#collaborator?' do
  let(:user) { 'peter-murach' }
  let(:repo) { 'github' }
  let(:collaborator) { 'octocat' }
  let(:request_path) { "/repos/#{user}/#{repo}/collaborators/#{collaborator}" }

  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) { '' }
    let(:status) { 204 }

    it "should fail to get resource without collaborator name" do
      expect {
        subject.collaborator? user, repo, nil
      }.to raise_error(ArgumentError)
    end

    it "should get the resource" do
      subject.collaborator? user, repo, collaborator
      a_get(request_path).should have_been_made
    end

    it "should find collaborator" do
      subject.should_receive(:collaborator?).
        with(user, repo, collaborator) { true }
      subject.collaborator? user, repo, collaborator
    end
  end

  context "resource not found" do
    let(:body) { '' }
    let(:status) { 404 }

    it "should fail to retrieve resource" do
      subject.should_receive(:collaborator?).
        with(user, repo, collaborator) { false }
      subject.collaborator? user, repo, collaborator
    end
  end
end # collaborator?

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
github_api-0.9.0 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.11 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.10 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.9 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.8 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.7 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.6 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.5 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.4 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.3 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.2 spec/github/repos/collaborators/get_spec.rb
github_api-0.8.1 spec/github/repos/collaborators/get_spec.rb