Sha256: e5313cf144761dd45b8eaad1a894c261ce33d77357c72002cb2e87b1bf5a6199

Contents?: true

Size: 967 Bytes

Versions: 6

Compression:

Stored size: 967 Bytes

Contents

require 'securerandom'

module CmQuiz
  module Review
    class GetUserInfo < BaseReview
      def initialize(project_api:)
        @project_api = project_api
        @verb = :get
        @path = '/me'
      end

      def run
        name = "codementor-test-#{SecureRandom.hex(5)}"
        email = "#{name}@codementor.io"
        password = "pAssw0rd!"
        jwt, _refresh_token = Factory::User.new({
          project_api: @project_api,
          name: name,
          email: email,
          password: password
        }).create

        res = send_get_user_info_request(jwt: jwt)
        payload = JSON.parse(res.body)

        expect(payload['email']).to eq(email)
        expect(payload['name']).to eq(name)
      end

      private

      def send_get_user_info_request(jwt:)
        @options = {
          headers: {
            'x-access-token' => jwt
          }
        }

        @project_api.request(@verb, @path, @options)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cm_quiz-0.0.8 lib/cm_quiz/review/get_user_info.rb
cm_quiz-0.0.7 lib/cm_quiz/review/get_user_info.rb
cm_quiz-0.0.6 lib/cm_quiz/review/get_user_info.rb
cm_quiz-0.0.5 lib/cm_quiz/review/get_user_info.rb
cm_quiz-0.0.4 lib/cm_quiz/review/get_user_info.rb
cm_quiz-0.0.3 lib/cm_quiz/review/get_user_info.rb