Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added default values for length and alphabet and added a test case fo…

…r them
  • Loading branch information...
commit 96c1979071d9b0298730b5ad3f7d45513c1d0189 1 parent 7a9bff8
@drd0rk authored
Showing with 12 additions and 5 deletions.
  1. +1 −1  lib/strgen.coffee
  2. +11 −4 test/test.coffee
View
2  lib/strgen.coffee
@@ -11,7 +11,7 @@ module.exports = class StrGen
"special_email": "-_."
"special_other": "@|:;#~'`?}{][&%$§!><+*/()"
- @alphabet = ""
+ @alphabet = @chars.abc.concat @chars.ABC.concat @chars.digits.concat @chars.special_email.concat @chars.special_other
# generates the random string
@generate: () ->
View
15 test/test.coffee
@@ -5,6 +5,13 @@ strgen = require '../'
vows
.describe('StrGen')
.addBatch
+ "when generating without configuring":
+ topic: () ->
+ strgen.generate()
+
+ "we get a string of length 64": (topic) ->
+ assert.equal topic.length,64
+
"when setting the alphabet to":
"all printable ascii characters":
topic: () ->
@@ -22,12 +29,12 @@ vows
"an error is thrown": (topic) ->
assert.throws () -> topic.setLength 1
- "64":
+ "76":
topic: () ->
- strgen.setLength 64
+ strgen.setLength 76
strgen.generate()
- "we get a string of length 64": (topic) ->
- assert.equal topic.length,64
+ "we get a string of length 76": (topic) ->
+ assert.equal topic.length,76
.exportTo(module)
Please sign in to comment.
Something went wrong with that request. Please try again.