Skip to content

Commit

Permalink
Increase test coverage. We now have 100% C0 coverage.
Browse files Browse the repository at this point in the history
Signed-off-by: Coda Hale <coda.hale@gmail.com>
  • Loading branch information
FooBarWidget authored and codahale committed Aug 12, 2009
1 parent f01304a commit 28e1375
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/bcrypt/engine_spec.rb
Expand Up @@ -29,6 +29,10 @@

context "Generating BCrypt hashes" do

class MyInvalidSecret
undef to_s
end

before :each do
@salt = BCrypt::Engine.generate_salt(4)
@password = "woo"
Expand All @@ -43,10 +47,15 @@
end

specify "should raise an InvalidSecret error if the secret is invalid" do
lambda { BCrypt::Engine.hash_secret(MyInvalidSecret.new, @salt) }.should raise_error(BCrypt::Errors::InvalidSecret)
lambda { BCrypt::Engine.hash_secret(nil, @salt) }.should_not raise_error(BCrypt::Errors::InvalidSecret)
lambda { BCrypt::Engine.hash_secret(false, @salt) }.should_not raise_error(BCrypt::Errors::InvalidSecret)
end

specify "should call #to_s on the secret and use the return value as the actual secret data" do
BCrypt::Engine.hash_secret(false, @salt).should == BCrypt::Engine.hash_secret("false", @salt)
end

specify "should be interoperable with other implementations" do
# test vectors from the OpenWall implementation <http://www.openwall.com/crypt/>
test_vectors = [
Expand Down

0 comments on commit 28e1375

Please sign in to comment.