Sha256: 51433b8fc84761fe7b54109797db22eeaeff04dbe1db26f67e20806cdf52cbc2

Contents?: true

Size: 1.53 KB

Versions: 7

Compression:

Stored size: 1.53 KB

Contents

require 'helper'

describe Octokit::Client do
  it 'should work with basic auth and password' do
    stub_get("https://foo:bar@api.github.com/repos/baz/quux/commits?per_page=35&sha=master").
      with(:headers => {'Accept'=>'*/*'}).
      to_return(:status => 200, :body => '{"commits":[]}', :headers => {})
    proc {
      Octokit::Client.new(:login => 'foo', :password => 'bar').commits('baz/quux')
    }.should_not raise_exception
  end

  it "should traverse a paginated response if auto_traversal is on" do
    stub_get("https://api.github.com/foo/bar").
      to_return(:status => 200, :body => %q{["stuff"]}, :headers => 
        { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last"} })

    stub_get("https://api.github.com/foo/bar?page=2").
      to_return(:status => 200, :body => %q{["even more stuff"]}, :headers => 
        { 'Link' => %q{<https://api.github.com/foo/bar?page=3>; rel="next", <https://api.github.com/foo/bar?page=3>; rel="last", <https://api.github.com/foo/bar?page=1>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })

    stub_get("https://api.github.com/foo/bar?page=3").
      to_return(:status => 200, :body => %q{["stuffapalooza"]}, :headers => 
        { 'Link' => %q{<https://api.github.com/foo/bar?page=2>; rel="prev", <https://api.github.com/foo/bar?page=1>; rel="first"} })

    Octokit::Client.new(:auto_traversal => true).get("https://api.github.com/foo/bar", {}, 3).should == ['stuff', 'even more stuff', 'stuffapalooza']
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
octokit-1.0.6 spec/octokit/client_spec.rb
octokit-1.0.5 spec/octokit/client_spec.rb
octokit-1.0.4 spec/octokit/client_spec.rb
octokit-1.0.3 spec/octokit/client_spec.rb
octokit-1.0.2 spec/octokit/client_spec.rb
octokit-1.0.1 spec/octokit/client_spec.rb
octokit-1.0.0 spec/octokit/client_spec.rb