Sha256: efdcb522f26fd4b46d7ca1ec1d19433a4f370bbfa70351b6f2c09c7b631e9198

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

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

module Doorkeeper::OAuth
  describe Client do
    describe :find do
      let(:method) { mock }

      it 'finds the client via uid' do
        client = stub
        method.should_receive(:call).with('uid').and_return(client)
        Client.find('uid', method).should be_a(Client)
      end

      it 'returns nil if client was not found' do
        method.should_receive(:call).with('uid').and_return(nil)
        Client.find('uid', method).should be_nil
      end
    end

    describe :authenticate do
      it 'returns the authenticated client via credentials' do
        credentials = Client::Credentials.new("some-uid", "some-secret")
        authenticator = mock
        authenticator.should_receive(:call).with("some-uid", "some-secret").and_return(stub)
        Client.authenticate(credentials, authenticator).should be_a(Client)
      end

      it 'retunrs nil if client was not authenticated' do
        credentials = Client::Credentials.new("some-uid", "some-secret")
        authenticator = mock
        authenticator.should_receive(:call).with("some-uid", "some-secret").and_return(nil)
        Client.authenticate(credentials, authenticator).should be_nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
couchkeeper-0.6.7 spec/lib/oauth/client_spec.rb