Sha256: 317e5d02d10ae8a1c95bb1bad6ea724a1d1905c598a8eded80f9b34cae0e7386

Contents?: true

Size: 690 Bytes

Versions: 2

Compression:

Stored size: 690 Bytes

Contents

require 'securerandom'

module CmQuiz
  module Factory
    class User
      def initialize(project_api:, name: nil, email: nil, password: nil)
        @project_api = project_api
        @name = name || "codementor-test-#{SecureRandom.hex(5)}"
        @email = email || "#{@name}@codementor.io"
        @password = password || "pAssw0rd!"
      end

      def create
        options = {
          body: {
            email: @email,
            name: @name,
            password: @password
          }
        }

        res = @project_api.request(:post, '/users', options)
        payload = JSON.parse(res.body)
        [payload['jwt'], payload['refresh_token']]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cm_quiz-0.0.2 lib/cm_quiz/factory/user.rb
cm_quiz-0.0.1 lib/cm_quiz/factory/user.rb