Duplicate error messages

I am running rails 1.2.3 and rspec 1.0.8 on os X 10.4 and I am having a
problem with one of my model specs (User class). For some reason rspec
is throwing repeating errors. If the error I expect is “email is
required”, I end up getting it several times. What’s even more
confusing, my spec passes without DRB, but with DRB is when all the
multiple errors show up. At the moment I have stripped away all but one
spec in the file, one that checks for errors when you validate a new
object but the problem still persists even with this very basic spec.
Any ideas would be greatly appreciated!

Thanks

On Dec 10, 2007 2:40 PM, Richard M. [email protected] wrote:

I am running rails 1.2.3 and rspec 1.0.8 on os X 10.4 and I am having a
problem with one of my model specs (User class). For some reason rspec
is throwing repeating errors. If the error I expect is “email is
required”, I end up getting it several times. What’s even more
confusing, my spec passes without DRB, but with DRB is when all the
multiple errors show up. At the moment I have stripped away all but one
spec in the file, one that checks for errors when you validate a new
object but the problem still persists even with this very basic spec.
Any ideas would be greatly appreciated!

how about some code and error messages

aslak

how about some code and error messages

aslak

Sorry, I should have done that earlier. At the moment I’m running a very
basic spec file, I’ve stripped out the rest as I figure this out.

user_spec.rb

require File.dirname(FILE) + ‘/…/spec_helper’

describe User, “when first created” do
before(:each) do
@user = User.new
end

it “should be invalid with 7 errors” do
@user.should_not be_valid
@user.errors.count.should == 7
end
end

In user.rb I have

validates_presence_of :first_name, :surname, :login, :email,
:mobile,
:message => “is required”

With DRB I get

ruby script/spec -X spec/models/user_spec.rb
F

‘User when first created should be invalid with 7 errors’ FAILED
expected: 7,
got: 32 (using ==)
./spec/models/user_spec.rb:10:

Finished in 0.026632 seconds

1 example, 1 failure

And without DRB I get

ruby script/spec spec/models/user_spec.rb
.

Finished in 0.190591 seconds

1 example, 0 failures

When I check the 32 errors above, I find repeating messages of email
required, first name required etc. I’m using svn and the whole spec was
actually working before (I really should have started using autotest
earlier). So something along the way got broke. I have 9 other models
and their specs work just fine. And in the web browser I only get the
expected 7 errors.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs