Created
February 10, 2011 11:36
-
-
Save kinnou02/820367 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 'spec_helper' | |
describe User do | |
it{ should have_field(:email).of_type(String) } | |
it{ should have_field(:username).of_type(String) } | |
it{ should have_field(:password_hash).of_type(String) } | |
it{ should have_field(:password_salt).of_type(String) } | |
it{ should have_field(:activation_token).of_type(String) } | |
it{ should have_field(:is_admin?).of_type(Boolean) } | |
it{ should have_field(:state).of_type(Boolean) } | |
it { should validate_presence_of(:email) } | |
it { should validate_presence_of(:password_hash) } | |
it { should validate_presence_of(:password_salt) } | |
it { should validate_presence_of(:username) } | |
it { should validate_uniqueness_of(:email) } | |
it { should validate_format_of(:email) } | |
it 'should have nil as token by default' do | |
User.new.activation_token.should == nil | |
end | |
it 'should\'nt be admin by default' do | |
User.new.is_admin?.should == false | |
end | |
it 'should\'nt be active by default' do | |
User.new.active?.should == false | |
end | |
it "should have one user in mongo" do | |
User.count == 1 | |
end | |
it "should fail if the last test pass" do | |
User.count == 0 | |
end | |
#describe "#authentificate" do | |
it "should return nil if no user match" do | |
User.authenticate("[email protected]", "something") == nil | |
end | |
it "should return the user if email and password match" do | |
#user = User.find(:first, :conditions => {:email => "[email protected]"}) | |
User.authenticate("[email protected]", "azerty") == User.first | |
end | |
it "should'nt authenticate the user if the password is wrong" do | |
User.authenticate("[email protected]", "something") == nil | |
end | |
#end | |
end |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment