Sha256: 72fa1049623a460b4a5fb7b03af29dfec9d57d1c20cd2e8bfef9e8cf37fa0164

Contents?: true

Size: 1.47 KB

Versions: 14

Compression:

Stored size: 1.47 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Activity::Notifications, '#get' do
  let(:thread_id) { 1 }
  let(:request_path) { "/notifications/threads/#{thread_id}" }

  before {
    stub_get(request_path).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('activity/threads.json') }
    let(:status) { 200 }

    it { should respond_to(:find) }

    it "should raise error when no thread-id parameter" do
      expect { subject.get }.to raise_error(ArgumentError)
    end

    it "should find resources" do
      subject.get thread_id
      a_get(request_path).should have_been_made
    end

    it "should return repository mash" do
      threads = subject.get thread_id
      threads.should be_an Enumerable
      threads.should have(1).items
    end

    it "should get repository information" do
      threads = subject.get thread_id
      threads.first.repository.name.should == 'Hello-World'
    end

    it "should yield repositories to a block" do
      subject.should_receive(:get).and_yield('octocat')
      subject.get(thread_id) { |repo| 'octocat' }
    end
  end

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

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

Version data entries

14 entries across 14 versions & 1 rubygems

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