Sha256: 43b559832697f1b747a9eea0e4700b491119978a31cc41798c36efa948caa02d

Contents?: true

Size: 1.46 KB

Versions: 26

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  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/branches.json') }
    let(:status) { 200 }

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

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

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

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

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

    it "should yield to a block" do
      block = lambda { |el| repo }
      subject.should_receive(:branches).with(user, repo).and_yield repo
      subject.branches(user, repo, &block)
    end
  end

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

end # branches

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
github_api-0.11.3 spec/github/repos/branches_spec.rb
github_api-0.11.2 spec/github/repos/branches_spec.rb
github_api-0.11.1 spec/github/repos/branches_spec.rb
github_api-0.11.0 spec/github/repos/branches_spec.rb
github_api-0.10.2 spec/github/repos/branches_spec.rb
github_api-0.10.1 spec/github/repos/branches_spec.rb
github_api-0.10.0 spec/github/repos/branches_spec.rb
github_api-0.9.7 spec/github/repos/branches_spec.rb
github_api-0.9.6 spec/github/repos/branches_spec.rb
github_api-0.9.5 spec/github/repos/branches_spec.rb
github_api-0.9.4 spec/github/repos/branches_spec.rb
github_api-0.9.3 spec/github/repos/branches_spec.rb
github_api-0.9.2 spec/github/repos/branches_spec.rb
github_api-0.9.1 spec/github/repos/branches_spec.rb
github_api-0.9.0 spec/github/repos/branches_spec.rb
github_api-0.8.11 spec/github/repos/branches_spec.rb
github_api-0.8.10 spec/github/repos/branches_spec.rb
github_api-0.8.9 spec/github/repos/branches_spec.rb
github_api-0.8.8 spec/github/repos/branches_spec.rb
github_api-0.8.7 spec/github/repos/branches_spec.rb