[rspec-users] Duplicate error messages

Richard Manyanza lists at ruby-forum.com
Mon Dec 10 10:08:26 EST 2007

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

require File.dirname(__FILE__) + '/../spec_helper'

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

  it "should be invalid with 7 errors" do
    @user.should_not be_valid
    @user.errors.count.should == 7

In user.rb I have
validates_presence_of     :first_name, :surname, :login, :email, 
                          :message => "is required"

With DRB I get
ruby script/spec -X spec/models/user_spec.rb

'User when first created should be invalid with 7 errors' FAILED
expected: 7,
     got: 32 (using ==)

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.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list