random_string helper function

This commit is contained in:
Devin Howard 2015-10-19 15:23:07 +08:00
parent d913f50cf9
commit e3a4207827

View file

@ -90,3 +90,8 @@ RSpec.configure do |config|
Kernel.srand config.seed
=end
end
def random_string(length = 10)
o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
string = (0...length).map { o[rand(o.length)] }.join
end