Sha256: 5c332ec35e762f2b2722fec115b62d33894813b1345bb72987f5d3d6ed24dfef

Contents?: true

Size: 1.17 KB

Versions: 6

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

6 entries across 6 versions & 1 rubygems

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