Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec_helper'
- describe User do
- let(:user) { Factory :user }
- describe "associations" do
- it { should have_many(:events) }
- it { should have_many(:realities) }
- end
- describe "validations" do
- it "is valid with default factory" do
- Factory.build(:user).should be_valid
- end
- describe "email" do
- it { should validate_presence_of(:email) }
- it "has valid format" do
- user.should validate_format_of(:email).with('user@example.com')
- user.should validate_format_of(:email).with('something+user@example.com')
- user.should_not validate_format_of(:email).with('user.example.com')
- end
- it "is unique" do
- new_user = Factory.build :user, :email => user.email
- User.should_receive(:find).and_return(user)
- new_user.should_not be_valid
- new_user.errors.messages.should have_key(:email)
- # new_user.errors.messages[:email].should == I18n.t('activerecord.errors.messages.taken')
- new_user.should validate_uniqueness_of(:email)
- end
- end
- it { should validate_presence_of :firstname }
- it { should validate_presence_of :lastname }
- describe "password" do
- it { should validate_presence_of(:password) }
- it { should ensure_length_of(:password).is_at_least(8).is_at_most(20) }
- it { should validate_presence_of(:password_confirmation) }
- end
- end # validations
- end
Add Comment
Please, Sign In to add comment