Module: RspecSupportMethods::Randomizer

Included in:
RspecSupportMethods
Defined in:
lib/rspec_support_methods/randomizer.rb

Overview

Helper methods for ramdom data

Instance Method Summary collapse

Instance Method Details

#rand_dateObject



16
17
18
19
# File 'lib/rspec_support_methods/randomizer.rb', line 16

def rand_date
  year = Time.now.year - 1
  "#{rand_fixnum(1, 28)}-#{rand_fixnum(1, 12)}-#{rand_fixnum(1960, year)}"
end

#rand_email(size = 5) ⇒ Object



4
5
6
# File 'lib/rspec_support_methods/randomizer.rb', line 4

def rand_email(size = 5)
  "#{rand_text(size)}@example.com"
end

#rand_fixnum(minimum, maximum) ⇒ Object



12
13
14
# File 'lib/rspec_support_methods/randomizer.rb', line 12

def rand_fixnum(minimum, maximum)
  (minimum..maximum).to_a.sample
end

#rand_text(size = 5) ⇒ Object



8
9
10
# File 'lib/rspec_support_methods/randomizer.rb', line 8

def rand_text(size = 5)
  ('a'..'z').to_a.sample(size).join
end