title: How do I test my devise user model validations using RSpec?
body: <p>I can find recommendations for testing devise user controllers and views in RSpec.  I've also seen suggestions that the devise gem code is already tested so it's not useful to spend a lot of time reinventing the wheel.  </p>
  
  <p>However, my user model has other fields that I need validated when the user signs up.  I'm using standard <code>validates...</code> statements in the user.rb model.  For example:</p>
  
  <pre><code>validates_presence_of     :nickname
  </code></pre>
  
  <p>I'm trying to use simple validation testing in my user_spec.rb, but when I try to create the user like this:</p>
  
  <pre><code>record = Factory.create(:user)
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>undefined method `encode!' for "Confirmation":String
  </code></pre>
  
  <p>The <code>encode!</code> method is not coming from my code, it must be one of the gems that devise is using, but I haven't been able to find it, yet.</p>
  
  <p>I've tried creating the user using User.new and Factory Girl.  I get the same error either way.  This spec was passing until I did an update of all my gems.  Unfortunately I didn't keep a note of everything that got updated at the time.  I've tried rolling devise back to previous versions but still get the same error.</p>
  
  <p>Rails 3, RSpec2</p>
  
  <p>Thanks for any advice.</p>