Sha256: c51a0b958dc08b08ddd705dc89eff88eda0fa97b18e1e037a6aef0df112938dd

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'
require 'omniauth-gaggleamp'

describe OmniAuth::Strategies::GaggleAMP do
  subject { OmniAuth::Strategies::GaggleAMP.new(nil) }

  it 'should add a camelization for itself' do
    OmniAuth::Utils.camelize('gaggleamp').should == 'GaggleAMP'
  end

  describe '#client' do
    it 'has correct GaggleAMP site' do
      subject.client.site.should eq('https://accounts.gaggleamp.com')
    end

    it 'has correct authorize url' do
      subject.client.options[:authorize_url].should eq('/oauth/authorize')
    end

    it 'has correct token url' do
      subject.client.options[:token_url].should eq('/oauth/token')
    end
  end

  describe '#callback_path' do
    it 'has the correct callback path' do
      subject.callback_path.should eq('/auth/gaggleamp/callback')
    end
  end

  describe '#uid' do
    before :each do
      subject.stub(:raw_info) { { 'id' => 'uid' } }
    end

    it 'returns the id from raw_info' do
      subject.uid.should eq('uid')
    end
  end

  describe '#info' do
    before :each do
      subject.stub(:raw_info) { {} }
    end

    context 'and therefore has all the necessary fields' do
      it { subject.info.should have_key :name }
      it { subject.info.should have_key :email }
      it { subject.info.should have_key :nickname }
    end
  end

  describe '#extra' do
    before :each do
      subject.stub(:raw_info) { { :foo => 'bar' } }
    end

    it { subject.extra['raw_info'].should eq({ :foo => 'bar' }) }
  end

  describe '#raw_info' do
    before :each do
      response = double('response', :parsed => { :foo => 'bar' })
      subject.stub(:access_token) { double('access token', :get => response) }
    end

    it 'returns parsed response from access token' do
      subject.raw_info.should eq({ :foo => 'bar' })
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-gaggleamp-0.1.0 spec/omniauth/strategies/gaggleamp_spec.rb
omniauth-gaggleamp-0.0.1 spec/omniauth/strategies/gaggleamp_spec.rb