Created
September 7, 2011 21:38
-
-
Save jaysonrowe/1201840 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 'spec_helper' | |
describe User do | |
before(:each) do | |
@attr = { | |
:name => "Example User", | |
:email => "[email protected]", | |
:password => "foobar", | |
:password_confirmation => "foobar" | |
} | |
end | |
it "should create a new instance given valid attributes" do | |
User.create!(@attr) | |
end | |
. | |
. | |
. | |
describe "password validations" do | |
it "should require a password" do | |
User.new(@attr.merge(:password => "", :password_confirmation => "")). | |
should_not be_valid | |
end | |
it "should require a matching password confirmation" do | |
User.new(@attr.merge(:password_confirmation => "invalid")). | |
should_not be_valid | |
end | |
it "should reject short passwords" do | |
short = "a" * 5 | |
hash = @attr.merge(:password => short, :password_confirmation => short) | |
User.new(hash).should_not be_valid | |
end | |
it "should reject long passwords" do | |
long = "a" * 41 | |
hash = @attr.merge(:password => long, :password_confirmation => long) | |
User.new(hash).should_not be_valid | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment