Sha256: 88a1e8c0fccdf3d97c595d7cc40ae2de23473f965fc9906f1f3c646942d6fe8c

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::PullRequests, '#list' do
  let(:repo) { 'github' }
  let(:user) { 'peter-murach' }
  let(:inputs) { { 'state'=> 'closed', 'unrelated' => true } }
  let(:request_path) { "/repos/#{user}/#{repo}/pulls" }

  before {
    stub_get(request_path).with(:query => inputs.except('unrelated')).
    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) { fixture('pull_requests/pull_requests.json') }
    let(:status) { 200 }

    it { should respond_to :all }

    it "throws error if pull_request id not provided" do
      expect { subject.list nil }.to raise_error(ArgumentError)
    end

    it "should get the resources" do
      subject.list user, repo, inputs
      a_get(request_path).with(:query => inputs).should have_been_made
    end

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

    it "should get pull request information" do
      pull_requests = subject.list user, repo, inputs
      pull_requests.first.title.should == 'new-feature'
    end

    it "should yield to a block" do
      yielded = []
      result = subject.list(user, repo, inputs) { |obj| yielded << obj }
      yielded.should == result
    end
  end

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

end # list

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
github_api-0.9.0 spec/github/pull_requests/list_spec.rb
github_api-0.8.11 spec/github/pull_requests/list_spec.rb
github_api-0.8.10 spec/github/pull_requests/list_spec.rb
github_api-0.8.9 spec/github/pull_requests/list_spec.rb
github_api-0.8.8 spec/github/pull_requests/list_spec.rb
github_api-0.8.7 spec/github/pull_requests/list_spec.rb