Rspec / Duplicate Errors for same object

Hi there,

I'm getting duplicate errors when I should only be receiving one error in the @errors array.

I have an Rspec test that looks like this:

describe ImageCollection, "validations" do   it "should require max_height to be numeric" do     collection = ImageCollection.create(:max_height => "xxx")     puts "Errors: #{collection.errors.inspect}"     collection.should have(1).error_on(:max_height)   end

  it "should require max_height to be numeric" do     collection = ImageCollection.create(:max_width => "xxx")     puts "Errors: #{collection.errors.inspect}"     collection.should have(1).error_on(:max_width)   end end

class ImageCollection < ActiveRecord::Base    validates_numericality_of :max_height, :max_width end

Nothing too fancy about that setup. When I run 'autotest' and print out what those errors are I see duplicate errors in the array for the same attribute.

I forgot to note this is on Edge Rails, and trunk of Rspec.

-Dave

I have an Rspec test that looks like this:

describe ImageCollection, "validations" do   it "should require max_height to be numeric" do     ...   end

  it "should require max_height to be numeric" do     ...   end end

Has anyone experienced these types of 'bugs'/'errors' before? Maybe I'm missing something obvious here.

I don't know if it's the cause, but you probably don't want two specs named the same thing here.

Notice how the 'max_height' attribute errors array has 2 entries for "is not a number". I'm only expecting 1 error, but I'm getting 2. Same goes for 'max_height'.

And there's a similar bug in the above paragraph... :wink:

I changed the specs to be named something different, but that still didn't fix it.

describe ImageCollection, "validations" do   it "should require max_height to be numeric" do     collection = ImageCollection.create(:max_height => nil, :max_width => 100, :is_active => false)     puts "Errors: #{collection.errors.inspect}"     collection.should have(1).error_on(:max_height)   end

  it "should require max_width to be numeric" do     collection = ImageCollection.create(:max_width => nil, :max_height => 100, :is_active => false)     puts "Errors: #{collection.errors.inspect}"     collection.should have(1).error_on(:max_width)   end end

I'm still getting duplicate errors.

1) 'ImageCollection validations should require max_width to be numeric' FAILED expected 1 error on :max_width, got 2 ./spec/models/image_collection_spec.rb:32: script/spec:4:

2) 'ImageCollection validations should require max_height to be numeric' FAILED expected 1 error on :max_height, got 2 ./spec/models/image_collection_spec.rb:26: script/spec:4:

One of the other guys that I work with checked out the project on his Red Hat box and all the tests pass. I went to check out a fresh copy on Leopard and I get these 2 errors. How odd!

Thanks, Dave