File: tokens_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 (42 lines) | stat: -rw-r--r-- 1,033 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
# frozen_string_literal: true

require 'securerandom'

describe Octokit::Client::Tokens do
  before do
    Octokit.reset!
    @client = basic_auth_client

    @app_client = Octokit::Client.new \
      client_id: test_github_client_id,
      client_secret: test_github_client_secret
  end

  after do
    Octokit.reset!
  end

  def note
    "Note #{SecureRandom.hex(20)}"
  end

  describe '.scopes', :vcr do
    it 'checks the scopes on the current token' do
      use_vcr_placeholder_for('dummytoken123456', 'SCOPE_AUTHORIZATION_TOKEN')

      token_client = Octokit::Client.new(access_token: 'dummytoken123456')

      expect(token_client.scopes).to be_kind_of Array
      assert_requested :get, github_url('/user')
    end

    it 'checks the scopes on a one-off token' do
      use_vcr_placeholder_for('dummytoken123456', 'ONE_OFF_SCOPE_AUTHORIZATION_TOKEN')

      Octokit.reset!

      expect(Octokit.scopes('dummytoken123456')).to be_kind_of Array
      assert_requested :get, github_url('/user')
    end
  end # .scopes
end