Sha256: 7f75dcff61dc891b075c8c7bc656fb29985af7f1123c1a11055b13eac8ab198f

Contents?: true

Size: 1.47 KB

Versions: 19

Compression:

Stored size: 1.47 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
      Credentials.new(nil, "something").should be_blank
      Credentials.new("something", nil).should be_blank
    end

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

      let(:method) do
        lambda { |request| return 'uid', 'secret' }
      end

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

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

      it 'stops at the first credentials found' do
        not_called_method = mock
        not_called_method.should_not_receive(:call)
        credentials = Credentials.from_request request, lambda { |r| }, method, not_called_method
      end

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

      it 'returns uid and secret from extractor method' do
        credentials = Credentials.from_request request, method
        credentials.uid.should    == 'uid'
        credentials.secret.should == 'secret'
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
doorkeeper-0.7.4 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.7.3 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.7.2 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.7.1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.7.0 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.7 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.6 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.5 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.4 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.3 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.2 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.0 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.6.0.rc1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.5.0 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.5.0.rc1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.4.2 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.4.1 spec/lib/oauth/client/credentials_spec.rb
doorkeeper-0.4.0 spec/lib/oauth/client/credentials_spec.rb