Sha256: 296dbd728d541efa440be426d5d5c7ac300b06bad04b7c4045a3e48902cbb0b7

Contents?: true

Size: 1.54 KB

Versions: 8

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe Rack::OAuth2::AccessToken do
  let :token do
    Rack::OAuth2::AccessToken::Bearer.new(
      access_token: 'access_token',
      refresh_token: 'refresh_token',
      expires_in: 3600,
      scope: [:scope1, :scope2]
    )
  end
  subject { token }

  its(:access_token)  { should == 'access_token' }
  its(:refresh_token) { should == 'refresh_token' }
  its(:expires_in)    { should == 3600 }
  its(:scope)         { should == [:scope1, :scope2] }
  its(:token_response) do
    should == {
      token_type: :bearer,
      access_token: 'access_token',
      refresh_token: 'refresh_token',
      expires_in: 3600,
      scope: 'scope1 scope2'
    }
  end

  context 'when access_token is missing' do
    it do
      expect do
        Rack::OAuth2::AccessToken::Bearer.new(
          refresh_token: 'refresh_token',
          expires_in: 3600,
          scope: [:scope1, :scope2]
        )
      end.to raise_error AttrRequired::AttrMissing
    end
  end

  context 'otherwise' do
    it do
      expect do
        Rack::OAuth2::AccessToken::Bearer.new(
          access_token: 'access_token'
        )
      end.not_to raise_error
    end
  end

  let(:resource_endpoint) { 'https://server.example.com/resources/fake' }
  [:get, :delete, :post, :put].each do |method|
    context 'when extension params given' do
      subject do
        Rack::OAuth2::AccessToken::Bearer.new(
          access_token: 'access_token',
          ex_key: :ex_value
        )
      end

      its(:raw_attributes) { should include :ex_key }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rack-oauth2-2.2.1 spec/rack/oauth2/access_token_spec.rb
rack-oauth2-2.2.0 spec/rack/oauth2/access_token_spec.rb
rack-oauth2-2.1.0 spec/rack/oauth2/access_token_spec.rb
rack-oauth2-2.0.1 spec/rack/oauth2/access_token_spec.rb
rack-oauth2-2.0.0 spec/rack/oauth2/access_token_spec.rb
rack-oauth2-2.0.0.rc3 spec/rack/oauth2/access_token_spec.rb
rack-oauth2-2.0.0.rc2 spec/rack/oauth2/access_token_spec.rb
rack-oauth2-2.0.0.rc1 spec/rack/oauth2/access_token_spec.rb