Created
October 17, 2011 03:56
-
-
Save azuby/1291908 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
| # == Schema Information | |
| # | |
| # Table name: users | |
| # | |
| # id :integer not null, primary key | |
| # activated :boolean | |
| # company_id :integer | |
| # employee_id :integer | |
| # first_name :string(255) | |
| # last_name :string(255) | |
| # role_id :integer | |
| # phone :string(255) | |
| # email :string(255) default(""), not null | |
| # encrypted_password :string(128) default(""), not null | |
| # reset_password_token :string(255) | |
| # reset_password_sent_at :datetime | |
| # sign_in_count :integer default(0) | |
| # current_sign_in_at :datetime | |
| # last_sign_in_at :datetime | |
| # current_sign_in_ip :string(255) | |
| # last_sign_in_ip :string(255) | |
| # created_at :datetime | |
| # updated_at :datetime | |
| # | |
| require 'spec_helper' | |
| describe User do | |
| before(:each) do | |
| @attr = { :first_name => "Example", | |
| :last_name => "User", | |
| :email => "user@example.com", | |
| :password => "secret", | |
| :password_confirmation => "secret" | |
| } | |
| end | |
| # Name validation tests | |
| it "should require a first name" do | |
| no_name_user = User.new(@attr.merge(:first_name => "")) | |
| no_name_user.should_not be_valid | |
| end | |
| it "should require a last name" do | |
| no_name_user = User.new(@attr.merge(:last_name => "")) | |
| no_name_user.should_not be_valid | |
| end | |
| it "should reject first names that are too long" do | |
| long_name = "a" * 51 | |
| long_name_user = User.new(@attr.merge(:first_name => long_name)) | |
| long_name_user.should_not be_valid | |
| end | |
| it "should reject last names that are too long" do | |
| long_name = "a" * 51 | |
| long_name_user = User.new(@attr.merge(:last_name => long_name)) | |
| long_name_user.should_not be_valid | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment