From: Phlip Date: 2007-09-03T12:10:08+09:00 Subject: Re: about assert_difference problem. help!! OnRails Ruby wrote: > def test_should_create_person > assert_difference people, :count do > person=Person.newly_created How is assert_difference expected to inflect "people" into "Person"? Or is people declared somewhere else? Use assert_latest: person = assert_latest Person do Person.newly_created # <-- you supply this, right? end assert person.new_record? Note that assert_latest returns nil, one item, or an [] array of items. So calling .new_record? on its return value is itself a test that one item appeared. > assert !person.new_record?, > "#{person.errors.full_messages.to_sentence}" That line says to flunk if person is not a new record; is this what you wanted? > people.yml > test1: Both assert_difference (which comes from various plugins, not from Rails) and assert_latest (which comes from http://www.oreillynet.com/onlamp/blog/2007/07/assert_latest_and_greatest.html ) don't detect fixtures, because they appear just before setup() time. -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax