Sha256: a7dcb1f8e8c77e1f60c9b40bef6d7281016317656fa1f4c5fa9b096cd6d22eca

Contents?: true

Size: 1.55 KB

Versions: 14

Compression:

Stored size: 1.55 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  after { reset_authentication_for subject }

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

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

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

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

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

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

    it "should get branch information" do
      teams = subject.teams user, repo
      teams.first.name.should == 'Owners'
    end

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

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

    it "should fail to get resource" do
      expect { subject.teams user, repo }.to raise_error(Github::Error::NotFound)
    end
  end
end # teams

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
github_api-0.8.11 spec/github/repos/teams_spec.rb
github_api-0.8.10 spec/github/repos/teams_spec.rb
github_api-0.8.9 spec/github/repos/teams_spec.rb
github_api-0.8.8 spec/github/repos/teams_spec.rb
github_api-0.8.7 spec/github/repos/teams_spec.rb
github_api-0.8.6 spec/github/repos/teams_spec.rb
github_api-0.8.5 spec/github/repos/teams_spec.rb
github_api-0.8.4 spec/github/repos/teams_spec.rb
github_api-0.8.3 spec/github/repos/teams_spec.rb
github_api-0.8.2 spec/github/repos/teams_spec.rb
github_api-0.8.1 spec/github/repos/teams_spec.rb
github_api-0.8.0 spec/github/repos/teams_spec.rb
github_api-0.7.2 spec/github/repos/teams_spec.rb
github_api-0.7.1 spec/github/repos/teams_spec.rb