0
require File.dirname(__FILE__) + '/../spec_helper'
0
describe BasicForgery do
0
- describe "
#password" do
0
+ describe "
.password" do
0
it "should only uppercase characters" do
0
BasicForgery.password(:allow_lower => false,
0
@@ -56,4 +56,114 @@ describe BasicForgery do
0
BasicForgery::UPPER_ALPHA)
0
\ No newline at end of file
0
+ describe ".encrypt" do
0
+ it "should encrypt to hex digits" do
0
+ BasicForgery.encrypt("something").should only_contain(BasicForgery::HEX_DIGITS)
0
+ it "should encrypt different words to different output" do
0
+ BasicForgery.encrypt("foo").should_not == BasicForgery.encrypt("bar")
0
+ it "should allow a salt that changes the output" do
0
+ BasicForgery.encrypt("foo", "baz").should_not == BasicForgery.encrypt("foo", "bar")
0
+ it "should have the same output when encrypting twice" do
0
+ BasicForgery.encrypt("foo", "bar").should == BasicForgery.encrypt("foo", "bar")
0
+ describe ".boolean" do
0
+ it "should return true or false" do
0
+ [true, false].should include(BasicForgery.boolean)
0
+ it "should return a random color" do
0
+ BasicForgery::COLORS.should include(BasicForgery.color)
0
+ it "should return a 6-character hex color" do
0
+ BasicForgery.hex_color.should match(/#(#{BasicForgery::HEX_DIGITS.join('|')}){6}/)
0
+ it "should return a 3-character hex color" do
0
+ BasicForgery.short_hex_color.should match(/#(#{BasicForgery::HEX_DIGITS.join('|')}){3}/)
0
+ it "should return a number >= the at_least option" do
0
+ BasicForgery.number(:at_least => 2).should >= 2
0
+ it "should return a number <= the at_most option" do
0
+ BasicForgery.number(:at_most => 12).should <= 12
0
+ it "should return text whose length is >= the at_least option" do
0
+ BasicForgery.text(:at_least => 5).size.should >= 5
0
+ it "should return text whose length is <= the at_most option" do
0
+ BasicForgery.text(:at_least => 15).size.should <= 15
0
+ it "should only uppercase characters" do
0
+ BasicForgery.text(:allow_lower => false,
0
+ :allow_numeric => false,
0
+ :allow_special => false).should only_contain(BasicForgery::UPPER_ALPHA)
0
+ it "should only contain lowercase characters" do
0
+ BasicForgery.text(:allow_lower => true,
0
+ :allow_upper => false,
0
+ :allow_numeric => false,
0
+ :allow_special => false).should only_contain(BasicForgery::LOWER_ALPHA)
0
+ it "should only contain numeric characters" do
0
+ BasicForgery.text(:allow_lower => false,
0
+ :allow_upper => false,
0
+ :allow_numeric => true,
0
+ :allow_special => false).should only_contain(BasicForgery::NUMERIC)
0
+ it "should only contain special characters" do
0
+ BasicForgery.text(:allow_lower => false,
0
+ :allow_upper => false,
0
+ :allow_numeric => false,
0
+ :allow_special => true).should only_contain(BasicForgery::SPECIAL_CHARACTERS)
0
+ it "should only contain lower and uppercase characters" do
0
+ BasicForgery.text(:allow_lower => true,
0
+ :allow_numeric => false,
0
+ :allow_special => false).should only_contain(BasicForgery::LOWER_ALPHA,
0
+ BasicForgery::UPPER_ALPHA)
0
+ it "should only contain numeric and special characters" do
0
+ BasicForgery.text(:allow_lower => false,
0
+ :allow_upper => false,
0
+ :allow_numeric => true,
0
+ :allow_special => true).should only_contain(BasicForgery::NUMERIC,
0
+ BasicForgery::SPECIAL_CHARACTERS)
0
+ it "should contain any of the defined characters" do
0
+ BasicForgery.text(:allow_lower => true,
0
+ :allow_numeric => true,
0
+ :allow_special => true).should only_contain(BasicForgery::NUMERIC,
0
+ BasicForgery::SPECIAL_CHARACTERS,
0
+ BasicForgery::LOWER_ALPHA,
0
+ BasicForgery::UPPER_ALPHA)
Comments
No one has commented yet.