[rspec-users] Possible Bug

Daniel N has.sox at gmail.com
Tue Jul 24 10:29:50 EDT 2007


I'm trying to test some code that has validates each and I've got a very
strange failure

Mock 'Book_1027' expected :store_with_privacy? with (#<Clip:0x1a99b96
@name="Clip_1025">) but received it with (#<Clip:0x1a99b96
@name="Clip_1025">)

The Spec

  it "should check that a book can save a clip" do
    @user = mock_model( User, :id => 3  )
    @clip = mock_model( Clip, :id => 1, :privacy => :public, :user => @user
)
    @book = mock_model( Book, :id => 2, :privacy => :public, :user => @user,
:user_id => @user.id  )

    @book.should_receive( :store_with_privacy? ).with( @clip )

    clipping = Clipping.new( valid_clipping_attributes.with( :clip => @clip,
:book => @book ) )
    clipping.valid?
end

And the model

class Clipping < AR:B
belongs_to :clip
belongs_to :book
...

  validates_each :clip do |model, attr, value|
    if !model.book.nil? && !model.clip.nil?
      if !model.book.store_with_privacy?( model.clip )
        model.errors.add( :clip, "You can't add this item to this book" )
      end
    end
  end

...
end

Any thoughts on what might be causing that?

Cheers
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070725/dd9d8127/attachment.html 


More information about the rspec-users mailing list