Sha256: 1f926d312356a4a7494abeb228b8f89394ce6442923a0e5db548a75348952c5a

Contents?: true

Size: 1.56 KB

Versions: 15

Compression:

Stored size: 1.56 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Activity::Starring, '#starred' do
  let(:user) { 'peter-murach' }
  let(:repo) { 'github' }

  after { reset_authentication_for subject }

  context "if user unauthenticated" do
    it "should fail to get resource without username " do
      stub_get("/user/starred").
        to_return(:body => '', :status => 401, :headers => {})
      expect { subject.starred }.to raise_error(Github::Error::Unauthorized)
    end

    it "should get the resource with username" do
      stub_get("/users/#{user}/starred").
        to_return(:body => fixture("repos/starred.json"), :status => 200, :headers => {})
      subject.starred :user => user
      a_get("/users/#{user}/starred").should have_been_made
    end
  end

  context "if user authenticated" do
    before do
      subject.oauth_token = OAUTH_TOKEN
      stub_get("/user/starred").
        with(:query => {:access_token => OAUTH_TOKEN}).
        to_return(:body => fixture("repos/starred.json"),
          :status => 200, :headers => {})
    end

    it "should get the resources" do
      subject.starred
      a_get("/user/starred").with(:query => {:access_token => OAUTH_TOKEN}).
        should have_been_made
    end

    it "should return array of resources" do
      starred = subject.starred
      starred.should be_an Enumerable
      starred.should have(1).items
    end

    it "should get starred information" do
      starred = subject.starred
      starred.first.name.should == 'Hello-World'
      starred.first.owner.login.should == 'octocat'
    end
  end
end # starred

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
github_api-0.11.3 spec/github/activity/starring/starred_spec.rb
github_api-0.11.2 spec/github/activity/starring/starred_spec.rb
github_api-0.11.1 spec/github/activity/starring/starred_spec.rb
github_api-0.11.0 spec/github/activity/starring/starred_spec.rb
github_api-0.10.2 spec/github/activity/starring/starred_spec.rb
github_api-0.10.1 spec/github/activity/starring/starred_spec.rb
github_api-0.10.0 spec/github/activity/starring/starred_spec.rb
github_api-0.9.7 spec/github/activity/starring/starred_spec.rb
github_api-0.9.6 spec/github/activity/starring/starred_spec.rb
github_api-0.9.5 spec/github/activity/starring/starred_spec.rb
github_api-0.9.4 spec/github/activity/starring/starred_spec.rb
github_api-0.9.3 spec/github/activity/starring/starred_spec.rb
github_api-0.9.2 spec/github/activity/starring/starred_spec.rb
github_api-0.9.1 spec/github/activity/starring/starred_spec.rb
github_api-0.9.0 spec/github/activity/starring/starred_spec.rb