# Assert\_latest now takes "polygamous" arguments

**URL:** <https://www.ruby-forum.com/t/assert-latest-now-takes-polygamous-arguments/147985>\
**Category:** Ruby\
**Created:** [September 8, 2008, 2:41am UTC](https://www.ruby-forum.com/t/assert-latest-now-takes-polygamous-arguments/147985 "2008-09-08T02:41:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [September 8, 2008, 2:41am UTC](https://www.ruby-forum.com/t/assert-latest-now-takes-polygamous-arguments/147985/1 "2008-09-08T02:41:10Z")

</div>

Rubies:

Those of you who dig ActiveRecord need this:

> **[O'Reilly Media - Technology and Business Training](https://www.oreilly.com)**
>
> Gain technology and business knowledge and hone your skills with learning resources created and curated by O'Reilly's experts: live online training, video, books, our platform has content from 200+ of the world's best publishers.

It shows how to write tests like this:

```
 t, fz = assert_latest T2, Foo do
           T2.create
           2.times{ Foo.create }
         end

 assert do
   t.id > 0 and
   fz[0].id > 0 and
   fz[1].id > fz[0].id
 end

```

The inner lines - T2.create etc. - represent your production code in  
action. You  
put the assert\_latest around that code, and it will detect any new  
records of  
the given type. You can then assert the records have the fields you  
expect.

This is useful for any kind of testing, but super-useful for integration  
tests,  
to detect large batches of new records.

Get assert\_latest with the assert\_efficient\_sql gem.
