Sha256: e6ecb5cdd83dff5a16368812d2e7300a58c554cfa3a7ba6d7c395c452476235f

Contents?: true

Size: 1.03 KB

Versions: 12

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper.rb'

describe Rack::OAuth2::Client::Grant::AuthorizationCode do
  let(:redirect_uri) { 'https://client.example.com/callback' }
  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 => redirect_uri}
      end
      subject { grant.new attributes }
      its(:redirect_uri) { should == redirect_uri }
      its(:to_hash) do
        should == {:grant_type => :authorization_code, :code => 'code', :redirect_uri => redirect_uri}
      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', :redirect_uri => nil}
      end
    end
  end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rack-oauth2-0.11.0 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.10.1 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.10.0 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.10.0.alpha spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.9.5 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.9.4 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.9.3 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.9.2 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.9.1 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.9.0 spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.9.0.alpha spec/rack/oauth2/client/grant/authorization_code_spec.rb
rack-oauth2-0.8.7 spec/rack/oauth2/client/grant/authorization_code_spec.rb