Class: Test::Helper
- Inherits:
-
Object
- Object
- Test::Helper
- Defined in:
- lib/authing_ruby/test/helper.rb
Instance Method Summary collapse
-
#randomNumString(n) ⇒ Object
随机数字字符串.
-
#randomString(length = 6) ⇒ Object
随机字母字符串,默认 6 位长度.
Instance Method Details
#randomNumString(n) ⇒ Object
随机数字字符串
11 12 13 14 15 16 17 |
# File 'lib/authing_ruby/test/helper.rb', line 11 def randomNumString(n) result = [] n.to_i.times do result << [0,1,2,3,4,5,6,7,8,9].sample end result.join end |
#randomString(length = 6) ⇒ Object
随机字母字符串,默认 6 位长度
5 6 7 8 |
# File 'lib/authing_ruby/test/helper.rb', line 5 def randomString(length = 6) endIndex = length % 26 ('a'..'z').to_a.shuffle[0,endIndex].join end |