Sha256: f749c57a09e2047bd19cf9e8ac4748e813258adbeba7e8d58107d0f9bd0a13d3

Contents?: true

Size: 1.75 KB

Versions: 4

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'

describe OmniAuth::Strategies::BonnierOauth2 do
  let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
  let(:parsed_response) { stub('ParsedResponse') }
  let(:response) { stub('Response', :parsed => parsed_response) }
  let(:access_token) { stub('AccessToken', :options => {}) }

  subject do
    args = ['appid', 'secret', @options || {}].compact
    OmniAuth::Strategies::BonnierOauth2.new(*args).tap do |strategy|
      allow(strategy).to receive(:request) {
        request
      }
    end
  end

  describe 'client options' do
    it 'should have correct name' do
      expect(subject.options.name).to eq('bonnier_oauth2')
    end

    it 'should have correct site' do
      expect(subject.options.client_options.site).to eq('http://localhost:3000')
    end

    it 'should have correct authorize url' do
      expect(subject.options.client_options.authorize_url).to eq('/api/oauth/authorize')
    end

    it 'should have correct token url' do
      expect(subject.options.client_options.token_url).to eq('/api/oauth/token')
    end
  end

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

    it 'returns the id from raw_info' do
      expect(subject.uid).to eq('123')
    end
  end

  describe "#info" do
    before :each do
      subject.stub(:raw_info) do
        {"user" => {'first_name' => "Mike", 'email' => "mike@example.com"}}
      end
    end

    it 'returns the first_name from raw_info' do
      expect(subject.info['first_name']).to eq('Mike')
    end

    it 'returns the email from raw_info as email' do
      expect(subject.info['email']).to eq('mike@example.com')
    end
  end

  describe "#extra" do
  end

  describe "#raw_info" do
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
omniauth-bonnier-oauth2-1.2.2 spec/omniauth/strategies/bonnier_oauth2_spec.rb
omniauth-bonnier-oauth2-1.2.0 spec/omniauth/strategies/bonnier_oauth2_spec.rb
omniauth-bonnier-oauth2-1.1.0 spec/omniauth/strategies/bonnier_oauth2_spec.rb
omniauth-bonnier-oauth2-1.0.0 spec/omniauth/strategies/bonnier_oauth2_spec.rb