Created
November 4, 2009 14:45
-
-
Save jwreagor/226089 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-core' | |
require 'dm-types' | |
require 'bacon' | |
DataMapper.setup :default, :adapter => :in_memory | |
class User | |
include DataMapper::Resource | |
property :id, Serial | |
property :password, BCryptHash, :nullable => true | |
end | |
describe "Hashing a user's password" do | |
before do | |
@user = User.create | |
@user.password = "password" | |
end | |
it "should set a password" do | |
@user.password.should.not.be.empty | |
end | |
it "should hash a password when read" do | |
@user.password.hash.should.not.be.nil | |
end | |
it "should identify the password" do | |
(@user.password == "password").should.be.true | |
end | |
it "should not identify the password" do | |
(@user.password == "not password").should.not.be.true | |
end | |
it "should provide the hash salt" do | |
@user.password.salt.should.not.be.empty | |
end | |
end | |
# more here, ok? http://bcrypt-ruby.rubyforge.org/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment