I had posted this on the regular Rails list, but upon trying this in
script/console, it seems like the behavior only exists when running rspec.
I'm getting some weird behavior in one of my models. I have a model
defined something like this
class User < ActiveRecord::Base
attr_accessor :password
validates_presence_of :password
end
If I validate the model without specifying a password, I get ["can't be
blank", "can't be blank"] for :password instead of just one "cant't be
blank". If I comment out the validates_presence_of statement, then no
errors. So it doesn't seem like it's being defined elsewhere(through a
plugin or some such). Any idea what might be going on here?
Like mentioned above, if I do this in script/console I only get "can't be
blank" once, as expected.
I should note that I'm not blaming rspec, moreso, where should I be
starting to look? My spec looks like this(snipped the other passing tests):
describe User do
include UserExampleHelperMethods
before(:each) do
@user = User.new
@user.password = '123456'
@user.password_confirmation = '123456'
end
it 'should be invalid without a password when creating' do
@user.attributes = valid_user_attributes
@user.password = nil
@user.password_confirmation = nil
@user.should_not be_valid
@user.errors.on(:password).should == "can't be blank"
end
end
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users