Sha256: 3962dd988c04ffc477d3dde065366625bcb44e3361588c51215bda98671e78be

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'securerandom'

module CmQuiz
  module Review
    class SignUpUser < BaseReview
      def initialize(project_api:)
        @project_api = project_api
        @verb = :post
        @path = '/users'
      end

      def run
        name = "codementor-test-#{SecureRandom.hex(5)}"
        email = "#{name}@codementor.io"
        password = "pAssw0rd!"
        res = send_sign_up_user_request(email: email, name: name, password: password)
        payload = JSON.parse(res.body)

        expect(payload['jwt'].class).to eq(String), '`jwt` should be string'
        expect(payload['refresh_token'].class).to eq(String), '`refresh_token` should be string'
        build_test_result(self.class)
      rescue RSpec::Expectations::ExpectationNotMetError => e
        build_test_result(self.class, false, e.message)
      rescue => e
        build_test_result(self.class, false, e.message)
      end

      private

      def send_sign_up_user_request(email:, name:, password:)
        options = {
          body: {
            email: email,
            name: name,
            password: password
          }
        }

        @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/sign_up_user.rb
cm_quiz-0.0.1 lib/cm_quiz/review/sign_up_user.rb