Sha256: 9f77ce403a4edf4b62837e11a30bde194558c5acd73d1f983066956a0ee50d72

Contents?: true

Size: 1.48 KB

Versions: 16

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'
require 'active_support/core_ext/string'
require 'doorkeeper/oauth/client'

class Doorkeeper::OAuth::Client
  describe Credentials do
    it 'is blank when any of the credentials is blank' do
      expect(Credentials.new(nil, 'something')).to be_blank
      expect(Credentials.new('something', nil)).to be_blank
    end

    describe :from_request do
      let(:request) { double.as_null_object }

      let(:method) do
        ->(_request) { return 'uid', 'secret' }
      end

      it 'accepts anything that responds to #call' do
        expect(method).to receive(:call).with(request)
        Credentials.from_request request, method
      end

      it 'delegates methods received as symbols to Credentials class' do
        expect(Credentials).to receive(:from_params).with(request)
        Credentials.from_request request, :from_params
      end

      it 'stops at the first credentials found' do
        not_called_method = double
        expect(not_called_method).not_to receive(:call)
        Credentials.from_request request, ->(_) {}, method, not_called_method
      end

      it 'returns new Credentials' do
        credentials = Credentials.from_request request, method
        expect(credentials).to be_a(Credentials)
      end

      it 'returns uid and secret from extractor method' do
        credentials = Credentials.from_request request, method
        expect(credentials.uid).to    eq('uid')
        expect(credentials.secret).to eq('secret')
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
doorkeeper-sequel-1.2.1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-4.2.0 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-4.1.0 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-4.0.0 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-4.0.0.rc4 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-4.0.0.rc3 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-4.0.0.rc2 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-4.0.0.rc1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-3.1.0 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-3.0.1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-2.2.2 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-3.0.0 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-3.0.0.rc2 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-3.0.0.rc1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-2.2.1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-2.2.0 spec/lib/oauth/client/credentials_spec.rb