Topic: need some help with shoulda unit test

I am writing some unit tests for my application to cover already existing functionality. 
I'm using machinist to create my factories - in this case for AppUser. 

when I write a test like so - 

subject { AppUser.make}   
should ensure_length_of(:password).is_at_least(6).with_message(/should be atleast 6 characters long/) 

for a validation like so - 

validates_presence_of   :password, :if => :password_required? 
validates_length_of     :password, :minimum => 6, :message =>"should be atleast 6 characters long", :if => :password_required?

the test fails with the following message -
Expected errors to include /should be atleast 6 characters long/ when password is set to "xxxxx", got no errors

This is probably because
AppUser.make.new_record? ==> false

Can anyone please help me get this to pass? Or is this an invalid unit test scenario?

Last edited by spacefugitive (2010-08-09 06:50:10)

Re: need some help with shoulda unit test

What does your machinist factory look like?