-
Notifications
You must be signed in to change notification settings - Fork 125
Forgery(:basic)
sheerun edited this page Aug 1, 2012
·
2 revisions
Returns either true
or false
, randomly.
Forgery(:basic).boolean
# => true
Forgery(:basic).boolean
# => false
Randomly generates the name of a color, with the first character uppercase, as a string.
Forgery(:basic).color
# => "Violet"
Derives the list of colors from dictionaries[:colors]
.
Creates a SHA1 hexdigest, with the current time as a salt. It takes two arguments:
- A string (default:
"password"
) - Any object, should be something that has a meaningful return to
.to_s
, (default:Time.now.to_s
)
Forgery(:basic).encrypt
# => "b2fbd3955a36068e93e0b9db45bcb178f08336f5"
Forgery(:basic).encrypt 'random-string'
# => "00932bafce4a9391f888ca77f81f98b8e89d3aa6"
Forgery(:basic).encrypt 'random-string', Time.utc(2009)
# => "4b157c2fbf430b962842d21926eaa887c3a12f81"
Returns random element from following array: ["Never", "Once", "Seldom", "Often", "Daily", "Weekly", "Monthly", "Yearly"]
Forgery(:basic).frequency
# => "Never"
Generates random number within given range.
Forgery(:basic).number(:at_least => 1, :at_most => 14)
# => 9
Generates password.
Currently basically alias for text
method with different defaults.
:at_least => 6, # minimum number of characters
:at_most => 12, # maximum number of characters
:allow_lower => true, # abcdefghijklmnopqrstuvwxyz
:allow_upper => true, # ABCDEFGHIJKLMNOPQRSTUVWXYZ
:allow_numeric => true, # 0123456789
:allow_special => false, # !'@\#$%^&*()_+-=[]{};:\",./?
:exactly => nil # exact number of characters
Forgery(:basic).password
# => "vLaETMv"
Allowed options along defaults:
:at_least => 10, # minimum number of characters
:at_most => 15, # maximum number of characters
:allow_lower => true, # abcdefghijklmnopqrstuvwxyz
:allow_upper => true, # ABCDEFGHIJKLMNOPQRSTUVWXYZ
:allow_numeric => true, # 0123456789
:allow_special => false, # !'@\#$%^&*()_+-=[]{};:\",./?
:exactly => nil # exact number of characters
Forgery(:basic).text
# => "GSoxkFJMjEJ9Cqm"
Forgery(:basic).hex_color
# => "#1bc23c"
Forgery(:basic).short_hex_color
# => "#8e7"