[rspec-users] Rate my code: refactoring from spec

Fernando Perez lists at ruby-forum.com
Thu Apr 16 04:35:43 EDT 2009

By the way in Rails I am now finding myself replacing: 
update_attributes, create! and their friends with something that looks 


Then in the spec I stub the save! method so that it doesn't hit the DB, 
and then I can easily compare the object attributes if they are as 

- specs are lightning fast

- data isn't actually inserted in DB, so there is a 0.000001% chance 
that the object has bad attributes that would raise an error if it was 
actually saved in DB. But that would mean that my spec is false as I 
myself set the comparison value.

Is it clever or not to do something like that? Maybe I can use that idea 
sometimes, and the other times it is safer to really save the object in 
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list