Sha256: 5463cc897286c705782e8c35dfb26884767fa4500066d535cfd8f700f4b64775

Contents?: true

Size: 717 Bytes

Versions: 3

Compression:

Stored size: 717 Bytes

Contents

shared_context 'stubbed edx requests' do
  let(:auth_code) { 'authcode' }
  let(:username)  { 'user' }

  let(:response_with_token) { { body: '{ "access_token": "access_token" },  "token_type": "Bearer", "expires_in": 3600' } }
  let(:response_with_user)  { { body: JSON.generate(authenticated_user_data), headers: { 'Content-Type' => 'application/json' } } }

  before do
    stub_request(:post, EdxAuthenticator::TOKEN_URL).
      with(body: hash_including(grant_type: 'authorization_code')).to_return(response_with_token)

    stub_request(:get, EdxAuthenticator::PROFILE_URL % { username: username }).
      with(headers: { 'Authorization'=>'Bearer access_token' }).
      to_return(response_with_user)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_api_auth-0.1.0 spec/support/shared_contexts/stubbed_edx_requests.rb
rails_api_auth-0.0.8 spec/support/shared_contexts/stubbed_edx_requests.rb
rails_api_auth-0.0.7 spec/support/shared_contexts/stubbed_edx_requests.rb