Created
July 25, 2010 03:35
-
-
Save zenom/489275 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 File.expand_path(File.dirname(__FILE__) + '/../test_config.rb') | |
context "Account" do | |
setup { Account.delete_all } | |
context "definition" do | |
setup { Account.make } | |
asserts_topic.has_field :name, :type => String | |
asserts_topic.has_field :surname, :type => String | |
asserts_topic.has_field :role, :type => String | |
asserts_topic.has_field :email, :type => String | |
asserts_topic.has_field :salt, :type => String | |
asserts_topic.has_field :crypted_password, :type => String | |
# responds to | |
asserts_topic.responds_to :password | |
asserts_topic.responds_to :password_confirmation | |
asserts_topic.has_validation :validates_presence_of, :email | |
# validates presence of | |
asserts_topic.has_validation :validates_presence_of, :email | |
asserts_topic.has_validation :validates_presence_of, :role | |
asserts_topic.has_validation :validates_presence_of, :password, :if => :password_required | |
asserts_topic.has_validation :validates_presence_of, :password_confirmation, :if => :password_required | |
# validates confirmation of | |
asserts_topic.has_validation :validates_confirmation_of, :password, :if => :password_required | |
# validates length of | |
asserts_topic.has_validation :validates_length_of, :password, :within => 4..40, :if => :password_required | |
asserts_topic.has_validation :validates_length_of, :email, :within => 3..100 | |
#validates uniqueness | |
asserts_topic.has_validation :validates_uniqueness_of, :email | |
# validates format of | |
asserts_topic.has_validation :validates_format_of, :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i | |
asserts_topic.has_validation :validates_format_of, :role, :with => /[A-Za-z]/ | |
end | |
context "authenticate method" do | |
setup { Account.make :password => 'test', :password_confirmation => 'test', :email => '[email protected]' } | |
asserts("passes") { Account.authenticate('[email protected]','test') } | |
asserts("fails") { Account.authenticate('[email protected]','fail') }.nil | |
end | |
context "password_clean method" do | |
setup { Account.make :password => 'password', :password_confirmation => 'password' } | |
asserts("success") { topic.password_clean }.equals 'password' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment