summaryrefslogtreecommitdiff
path: root/spec/trocla/util_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/trocla/util_spec.rb')
-rw-r--r--spec/trocla/util_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/trocla/util_spec.rb b/spec/trocla/util_spec.rb
new file mode 100644
index 0000000..879b244
--- /dev/null
+++ b/spec/trocla/util_spec.rb
@@ -0,0 +1,28 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe "Trocla::Util" do
+
+ { :random_str => 12, :salt => 8 }.each do |m,length|
+ describe m do
+ it "should be random" do
+ Trocla::Util.send(m).should_not eql(Trocla::Util.send(m))
+ end
+
+ it "should default to length #{length}" do
+ Trocla::Util.send(m).length.should == length
+ end
+
+ it "should be possible to change length" do
+ Trocla::Util.send(m,8).length.should == 8
+ Trocla::Util.send(m,32).length.should == 32
+ Trocla::Util.send(m,1).length.should == 1
+ end
+ end
+ end
+
+ describe :salt do
+ it "should only contain characters and numbers" do
+ Trocla::Util.salt =~ /^[a-z0-9]+$/i
+ end
+ end
+end