-
-
Save tubbo/11405232 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 | |
| it "has a valid factory" do | |
| build(:user).should be_valid | |
| end | |
| it "is invalid without an email" do | |
| build(:user, email: nil).should_not be_valid | |
| end | |
| it "is invalid if the username is shorter than 3 characters" do | |
| build(:user, username: 'ln').should_not be_valid | |
| end | |
| it "is invalid if password is shorter than 6 characters" do | |
| build(:user, password: '12345', password_confirmation: '12345').should_not be_valid | |
| end | |
| it "is invalid if password doesn't match" do | |
| build(:user, password: 'test123', password_confirmation: 'test321').should_not be_valid | |
| end | |
| it "is invalid if username is not unique" do | |
| create(:user, username: 'ellen.u').should be_valid | |
| create(:user, username: 'ellen.u').should be_valid | |
| end | |
| it "is invalid if email is not unique" do | |
| create(:user, email: '[email protected]').should be_valid | |
| create(:user, email: '[email protected]').should be_valid | |
| end | |
| end |
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 'faker' | |
| FactoryGirl.define do | |
| factory :user do | |
| email {Faker::Internet.email} | |
| username {Faker::Internet.user_name} | |
| first_name {Faker::Name.first_name} | |
| last_name {Faker::Name.last_name} | |
| password 'test123' | |
| password_confirmation 'test123' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment