Thursday, July 17, 2008

Use blank fixtures for Bj tables when testing with Bj

I have an integration test where I need to test a web process that starts a background process with Ara T Howard's awesomely named Bj plugin (Background Job - but never has overhearing talk about Rails testing cause so many funny looks and stifled laughs).

I found some great notes here: which show how to wait for a job to finish during a test.

One problem I ran into, though, was that I somehow had a bad job that got stuck in the testing database table, and that was messing up testing results because Bj would wake up during the test, see the old bad job, and resubmit it. It took a while to track that down.

I fixed it by simply putting blank fixtures in test/fixtures for each of the Bj tables: bj_config, bj_job, and bj_job_archive. That way Bj starts from a blank slate when each test starts. There's a Bj protip for you. Another one is to watch the Bj logs for the test environment.

No comments: