Sha256: 3618ec9d4f5e13a97eb32797e1aa3bb7999b508f70af19cbebdc8f2183a7cca3

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe OmniAuth::Strategies::Inspur do
  let(:access_token) { double('AccessToken') }
  let(:parsed_response) { double('ParsedResponse') }
  let(:response) { double('Response', parsed: parsed_response) }

  let(:enterprise_site) { 'https://some.other.site.com/api/v3' }

  let(:inspur_service) { OmniAuth::Strategies::Inspur.new({}) }
  let(:enterprise) do
    OmniAuth::Strategies::Inspur.new(
      'INSPUR_KEY',
      'INSPUR_SECRET',
      client_options: { site: enterprise_site },
      redirect_url: 'http://localhost:9292/callback_url'
    )
  end

  subject { inspur_service }

  before(:each) do
    allow(subject).to receive(:access_token).and_return(access_token)
  end

  describe 'client options' do
    context 'with defaults' do
      subject { inspur_service.options.client_options }

      its(:site) { is_expected.to eq 'https://inspur.com/api/v4' }
    end

    context 'with override' do
      subject { enterprise.options.client_options }

      its(:site) { is_expected.to eq enterprise_site }
    end
  end

  describe 'redirect_url' do
    context 'with defaults' do
      subject { inspur_service.options }
      its(:redirect_url) { is_expected.to be_nil }
    end

    context 'with customs' do
      subject { enterprise.options }
      its(:redirect_url) { is_expected.to eq 'http://localhost:9292/callback_url' }
    end
  end

  describe '#raw_info' do
    it 'sent request to current user endpoint' do
      expect(access_token).to receive(:get).with('user').and_return(response)
      expect(subject.raw_info).to eq(parsed_response)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-inspur-1.0.0 spec/omniauth/strategies/inspur_spec.rb