On 1/11/07, Angrez Singh <[EMAIL PROTECTED]> wrote:

Hi Sarita,

chars = ("a".."z").to_a + ("A".."Z").to_a
random_string = ""
1.upto(5) { |i| random_string << chars[rand(chars.length - 1)] }
puts random_string


Here's a slightly different take that I posted to the agile-testing mail
list some time ago:

def random_text( length )
 output = ""
 length.times do
   output << ('A'..'Z').to_a[ rand(26) ]
 end
 output
end

then, where ever you need it : just call it

random_text( 42 )  # for 42 chars of random text ...
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to