Class: Apicraft::Mocker::String

Inherits:
Base
  • Object
show all
Defined in:
lib/apicraft/mocker/string.rb

Overview

Generate fake values for string data types

Instance Attribute Summary

Attributes inherited from Base

#schema

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Apicraft::Mocker::Base

Instance Method Details

#mockObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/apicraft/mocker/string.rb', line 7

def mock
  return enum.sample if enum.present?

  return Faker::Internet.email if format == "email"

  return Faker::Internet.url if format == "uri"

  return Faker::Internet.uuid if format == "uuid"

  return Faker::Time.backward.iso8601 if format == "date-time"

  Faker::Lorem.word
end