Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module UserSpecHelper
- def valid_user_attributes
- { :email => 'joe@bloggs.com',
- :username => 'joebloggs',
- :password => 'abcdefg' }
- end
- end
- context "A user (in general)" do
- include UserSpecHelper
- def setup
- @user = User.new
- end
- specify "should be invalid without a username" do
- @user.attributes = valid_user_attributes.except(:username)
- @user.should_not_be_valid
- @user.errors.on(:username).should_equal "is required"
- end
- specify "should be invalid without an email" do
- @user.attributes = valid_user_attributes.except(:email)
- @user.should_not_be_valid
- @user.errors.on(:email).should_equal "is required"
- end
- specify "should be invalid without a password" do
- @user.attributes = valid_user_attributes.except(:password)
- @user.should_not_be_valid
- end
- specify "should be valid with a full set of valid attributes" do
- @user.attributes = valid_user_attributes
- @user.should_be_valid
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement