[rspec-users] Test::Unit Functional failure puzzle

James Byrne lists at ruby-forum.com
Fri Nov 21 09:44:38 EST 2008

David Chelimsky wrote:

> Without seeing the controller code, I'd guess that the controller uses
> create, and not create! and that a validation failure is not getting
> reported anywhere.
> If so, try changing create to create! and you should get your error.

Thank you. You were close enough to the actual situation that I could 
easily see what had to be done.

The main problem (other than my abysmal ignorance) is that I am 
retro-fitting test to code that I wrote some time ago.  In this case 
client is a role associated to an entity.  The clients_controller 
handles the case where the entity and the client are created together in 
one pass.  I was creating a new client but not a new entity in my test 
case and so the save was failing because the entity validations were 
failing.  Changing the .save to .save! displayed the actual error in the 
test and made the entire situation clear to me.

My next question is: why would one choose .save/.create over 
.save!/.create! since the former does not render the error when testing?
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list