validate username characters and length

This commit is contained in:
2011-03-02 00:54:04 +00:00
parent 56984a0ecb
commit 5b661e0264
3 changed files with 45 additions and 20 deletions

View File

@@ -18,8 +18,18 @@ describe Twhois do
end
it "should return error on unknown user" do
user = Twhois.lookup('jimehoawhefoahelfhasdf')
user = Twhois.lookup('akjsdfkjasdfasd')
user.should be_nil
end
it "should raise an exception on invalid usernames" do
lambda { # invalid characters
user = Twhois.lookup("abc/damn")
}.should raise_error(Twhois::InvalidUsername)
lambda { # longer than 15 characters
user = Twhois.lookup("abcasdjfakajsdfasdfasdfa")
}.should raise_error(Twhois::InvalidUsername)
end
end