[rspec-users] rspec causing validates_presence_of to validate twice?

Steve vertebrate at gmail.com
Thu Oct 18 00:35:58 EDT 2007

On Wed, 17 Oct 2007 21:31:19 -0500, David Chelimsky wrote:
> This all may be true but I can't help you diagnose the problem without
> looking at the code. If you'd kindly pastie the spec and model, I'll
> be glad to look at them. Otherwise I'm just guessing and that's not
> working out to well so far.

Rather than burden you with it in its uber-long glory, I started trying to
rebuild the file piecemeal until failure. What I found is that this
behavior was causing it to fail:

it 'should only allow access to the username, first_name, last_name, and email address fields' do
  #User.should_receive(:attr_accessible).with(:username, :first_name, :last_name, :email_address)
  #load "#{RAILS_ROOT}/app/models/user.rb"

You may recall that from a post I made a few days ago. It seems like a
"duh" moment now. Of course the "load" statement re-evals the class,
and just adds to the existing version that Ruby knows about. How would you
get around this though? Can you?

More information about the rspec-users mailing list