File: feeds_spec.rb

package info (click to toggle)
ruby-octokit 10.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,092 kB
  • sloc: ruby: 13,339; sh: 99; makefile: 7; javascript: 3
file content (45 lines) | stat: -rw-r--r-- 1,372 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

describe Octokit::Client::Feeds do
  before do
    Octokit.reset!
  end

  describe '.feeds', :vcr do
    context 'when unauthenticated' do
      it 'returns the public feeds list' do
        feeds = Octokit.feeds
        expect(Octokit.user_authenticated?).to be false
        expect(feeds.rels[:timeline].href).to be
        expect(feeds.rels[:current_user_public]).to be_nil
      end
    end

    context 'when authenticated with oauth token' do
      it 'returns the authenticated users feeds' do
        feeds = oauth_client.feeds
        expect(oauth_client.user_authenticated?).to be true
        expect(feeds.rels[:current_user_public].href).to be
      end
    end

    context 'when authenticated with basic auth' do
      it 'returns private feeds' do
        feeds = basic_auth_client.feeds
        expect(basic_auth_client.user_authenticated?).to be true
        expect(feeds.rels[:current_user].href).to be
        expect(feeds.rels[:current_user_actor].href).to be

        token = feeds.rels[:current_user].href.match(/token=(\w+)/)
        use_vcr_placeholder_for(token, '<<ACCESS_TOKEN>>')
      end
    end
  end # .feeds

  describe '.feed', :vcr do
    it 'returns parsed feed data' do
      feed = Octokit.feed(:timeline)
      expect(feed.title.content).to eq('GitHub Public Timeline Feed')
    end
  end # .feed
end