Sha256: 5ebd928aa367affed0b9d28f4325bba91161f0ff23c264a6aede23d62a53a3f2

Contents?: true

Size: 1.51 KB

Versions: 12

Compression:

Stored size: 1.51 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Activity::Watching, '#watched' do
  let(:user) { 'peter-murach' }

  after { reset_authentication_for subject }

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

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

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

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

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

    it "should get watched information" do
      watched = subject.watched
      watched.first.name.should == 'Hello-World'
    end
  end
end # watched

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
github_api-0.8.11 spec/github/activity/watching/watched_spec.rb
github_api-0.8.10 spec/github/activity/watching/watched_spec.rb
github_api-0.8.9 spec/github/activity/watching/watched_spec.rb
github_api-0.8.8 spec/github/activity/watching/watched_spec.rb
github_api-0.8.7 spec/github/activity/watching/watched_spec.rb
github_api-0.8.6 spec/github/activity/watching/watched_spec.rb
github_api-0.8.5 spec/github/activity/watching/watched_spec.rb
github_api-0.8.4 spec/github/activity/watching/watched_spec.rb
github_api-0.8.3 spec/github/activity/watching/watched_spec.rb
github_api-0.8.2 spec/github/activity/watching/watched_spec.rb
github_api-0.8.1 spec/github/activity/watching/watched_spec.rb
github_api-0.8.0 spec/github/activity/watching/watched_spec.rb