Sha256: 8973cbc62633c59ac2f4c51497dd65f3a199b3f1edbaddae846e2cecfd72dc19

Contents?: true

Size: 965 Bytes

Versions: 2

Compression:

Stored size: 965 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

2 entries across 2 versions & 1 rubygems

Version Path
cm_quiz-0.0.2 lib/cm_quiz/review/get_user_info.rb
cm_quiz-0.0.1 lib/cm_quiz/review/get_user_info.rb