Module: FixtureReplacement::RandomDataGenerators

Included in:
ClassMethods
Defined in:
lib/fixture_replacement/random_data_generators.rb

Instance Method Summary collapse

Instance Method Details

#random_email(*args) ⇒ Object



16
17
18
19
# File 'lib/fixture_replacement/random_data_generators.rb', line 16

def random_email(*args)
  require 'faker'
  Faker::Internet.email(*args)
end

#random_first_nameObject



21
22
23
24
# File 'lib/fixture_replacement/random_data_generators.rb', line 21

def random_first_name
  require 'faker'
  Faker::Name.first_name
end

#random_incrementing_numberObject



10
11
12
13
14
# File 'lib/fixture_replacement/random_data_generators.rb', line 10

def random_incrementing_number
  @increment ||= 0
  @increment += 1
  @increment
end

#random_last_nameObject



26
27
28
29
# File 'lib/fixture_replacement/random_data_generators.rb', line 26

def random_last_name
  require 'faker'
  Faker::Name.last_name
end

#random_nameObject



31
32
33
34
# File 'lib/fixture_replacement/random_data_generators.rb', line 31

def random_name
  require 'faker'
  Faker::Name.name
end

#random_string(length = 10) ⇒ Object



3
4
5
6
7
8
# File 'lib/fixture_replacement/random_data_generators.rb', line 3

def random_string(length=10)
  chars = ("a".."z").to_a
  string = ""
  1.upto(length) { |i| string << chars[rand(chars.size-1)]}
  string
end