[rspec-users] Error when mocking a method in a class

Juanma Cervera lists at ruby-forum.com
Mon Dec 29 09:31:07 EST 2008

David Chelimsky wrote:

> I'm not really sure why this is stubbing find, or why the stub value
> is true instead of a model. Actually, I don't even see how this would
> specify validating uniqueness of the attribute without very specific
> setup:
> first = Centro.create(:nombre => "example")
> second = Centro.create(:nombre => "example")
> second.should validate_uniqueness_of(:nombre)

I see how it works, I think.
When the matcher calls the 'valid?' method in the object, it makes the 
call to the find method of the class only if we have specified the 
validates_uniqueness_of method in our model, if this return something 
then the object is not valid, this is what we are stubbing, no?

But, as I said in a message before, I think the problem is with the 
names of the models or the attributes. I can send a tar file with a very 
simple app as an attachemnt if you want, that exhibits the problem.

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

More information about the rspec-users mailing list