Class: CmQuiz::Review::SignUpUser

Inherits:
BaseReview show all
Defined in:
lib/cm_quiz/review/sign_up_user.rb

Instance Attribute Summary

Attributes inherited from BaseReview

#options, #path, #verb

Instance Method Summary collapse

Methods inherited from BaseReview

#build_test_result, #perform, #test_request

Methods included from CmQuiz::ReviewHelper

#be, #be_nil, #be_within, #eq, #expect

Constructor Details

#initialize(project_api:) ⇒ SignUpUser

Returns a new instance of SignUpUser.



6
7
8
9
10
# File 'lib/cm_quiz/review/sign_up_user.rb', line 6

def initialize(project_api:)
  @project_api = project_api
  @verb = :post
  @path = '/users'
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cm_quiz/review/sign_up_user.rb', line 12

def run
  name = "codementor-test-#{SecureRandom.hex(5)}"
  email = "#{name}@codementor.io"
  password = "pAssw0rd!"
  res = (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