P
Phlip
Rubies:
Those of you who dig ActiveRecord need this:
http://www.oreillynet.com/ruby/blog/2008/09/polygamous_assert_latest.html
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.
Those of you who dig ActiveRecord need this:
http://www.oreillynet.com/ruby/blog/2008/09/polygamous_assert_latest.html
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.