# Duplicate error messages

**URL:** <https://www.ruby-forum.com/t/duplicate-error-messages/122664>\
**Category:** RSpec\
**Created:** [December 10, 2007, 2:40pm UTC](https://www.ruby-forum.com/t/duplicate-error-messages/122664 "2007-12-10T14:40:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liseki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/7ab992/32.png) [@liseki](https://www.ruby-forum.com/u/liseki)\
**Post date:** [December 10, 2007, 2:40pm UTC](https://www.ruby-forum.com/t/duplicate-error-messages/122664/1 "2007-12-10T14:40:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![liseki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/7ab992/32.png) [@liseki](https://www.ruby-forum.com/u/liseki)\
**Post date:** [December 10, 2007, 3:36pm UTC](https://www.ruby-forum.com/t/duplicate-error-messages/122664/2 "2007-12-10T15:36:00Z")

</div>

On Dec 10, 2007 2:40 PM, Richard M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![liseki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/7ab992/32.png) [@liseki](https://www.ruby-forum.com/u/liseki)\
**Post date:** [December 10, 2007, 4:08pm UTC](https://www.ruby-forum.com/t/duplicate-error-messages/122664/3 "2007-12-10T16:08:26Z")

</div>

> 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

1. 

‘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.
