small medium large xlarge

20 Mar 2009, 16:24
SC (15 posts)

Has this been deprecated? I’m trying to write some tests


category = => “Some category”) assert_valid?(category)

And rake test:units keep returning NoMethodError: undefined method etc

I looked up the source and it said that it was depcreated and to use assert record.valid? instead? Anyone confirm this?

Cheers Simon

20 Mar 2009, 20:29
Sam Ruby (633 posts)

Try “assert_valid”: , i.e., without the trailing question mark.

13 May 2011, 15:30
Brent Nordquist (4 posts)

It seems @assert_valid object@ is deprecated now, in favor of @assert object.valid?@

But this page had a good idea: Implement @assert_valid()@ as a test helper, which dumps the error(s) out so you can easily see why it didn’t validate:

def assert_valid(record) 
  assert record.valid?, record.errors.full_messages.join("\n") 
You must be logged in to comment