Sha256: 1427e5d70c662f65681670197689c7e4b93c517a0f4fae17132792160cfa94be

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper.rb'

describe Rack::OAuth2::Client::Grant::AuthorizationCode do
  let(:grant) { Rack::OAuth2::Client::Grant::AuthorizationCode }

  context 'when code is given' do
    let :attributes do
      {:code => 'code'}
    end

    context 'when redirect_uri is given' do
      let :attributes do
        {:code => 'code', :redirect_uri => 'https://client.example.com/callback'}
      end
      subject { grant.new attributes }
      its(:redirect_uri) { should == 'https://client.example.com/callback' }
      its(:to_hash) do
        should == {:grant_type => :authorization_code, :code => 'code', :redirect_uri => 'https://client.example.com/callback'}
      end
    end

    context 'otherwise' do
      subject { grant.new attributes }
      its(:redirect_uri) { should be_nil }
      its(:to_hash) do
        should == {:grant_type => :authorization_code, :code => 'code'}
      end
    end
  end

  context 'otherwise' do
    it do
      expect { grant.new }.should raise_error AttrRequired::AttrMissing
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-oauth2-0.8.6 spec/rack/oauth2/client/grant/authorization_code_spec.rb