[rspec-users] mongo_mapper validations, rpsec

Chris Habgood chabgood at gmail.com
Sat Sep 3 17:17:24 EDT 2011


I have a basic user class and doing rspec validations.  When I do a factory 
create to produce validations it blows up before I can get to the second 
line to check for errors.  Ideas how to get this to perform like AR 
Validations?

MongoMapper::DocumentNotValid:
       Validation failed: Password can't be blank, Email can't be blank, 
Password digest can't be blank

class User
  include MongoMapper::Document
  include ActiveModel::SecurePassword
  
  attr_accessible :email, :password
  
  key :password_digest, String
  key :password, String, :required => true
  key :email, String, :required => true
      
  has_secure_password
end

it "should not authenticate with incorrect password" do
      user = Factory(:user, :email=> '', :password => '').should 
have(2).errors
      #user.should have(2).errors #_on(:name)
  end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110903/9c7b9378/attachment.html>


More information about the rspec-users mailing list