Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'dm-core'
- require 'dm-types'
- DataMapper.setup(:default, 'sqlite3::memory:')
- class Test
- include DataMapper::Resource
- property :id, Serial
- property :password, BCryptHash
- end
- Test.auto_migrate!
- # Create new object
- @t = Test.new(:password => 'hi')
- @t.save
- # Reload the object
- @t = nil
- @t = Test.first
- # Capture and test values
- v1 = @t.password.to_s #For the raw hash value
- @t.save
- @t = Test.first
- v2 = @t.password.to_s #For the new hash values
- v1 == v2
- @t.password == 'hi'
- @t.password == v1
- ## Why isn't it equal if I haven't changed the password
Add Comment
Please, Sign In to add comment