Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add random_string function

  • Loading branch information...
commit a0c712f16a86a03ec5d3097c6db8631e2dcb1afd 1 parent 637e48b
@hayamiz authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 test/server.rb
View
9 test/server.rb
@@ -15,8 +15,11 @@
$katakana = (0x30A0..0x30FF).to_a
$cjk_kanji = (0x4E00..0x9FFF).to_a
-def random_string
-
+def random_string(chars, length_min, length_max)
+ len = length_min + rand(length_max - length_min + 1)
+ Array.new(len).map{ |x|
+ chars.choice
+ }.pack('U*')
end
class User
@@ -34,7 +37,7 @@ def self.generate(id = nil)
def initialize(id)
@attrs = Hash.new
@attrs[:id] = id
- @attrs[:name] = 'a'
+ @attrs[:name] =
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.