Sha256: c2a027cb641ee0ffe4d4c0ca9cffae95fde359cee375d6f84827b5ab6cec4b4c

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

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

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

    it "should return repository mash" do
      repo_branch = subject.branch user, repo, branch
      repo_branch.should be_a Hashie::Mash
    end

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

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