ARTS and Rails 1.2

I recently ran into some problems when upgrading an application from Rails 1.1 to Rails 1.2. RJS tests (using ARTS) that previously worked fine suddenly started failing (cannot find X in response, when I could see X in the response, right in front of me).

I dived into the ARTS code and came to the following conclusion: the JavaScriptGenerator has changed in some way; in particular, each fragment of JavaScript was separated by a newline before and is not any more. The original ARTS code would split the response into an array of strings (split by newlines) and then use Array#include? to look for the fragment. I have changed it to look like this:

def assert_rjs(action, *args, &block) if respond_to?("assert_rjs_#{action}")   send("assert_rjs_#{action}", *args) else   assert @response.body.to_s.index(create_generator.send(action, *args, &block)), generic_error(action, args) endend

In other words, instead of splitting into lines and looking for an exact match, I simply examine the entire response body for the fragment. I have reported this to Kevin Clark (he says he has had no problems with edge rails, but maybe that has changed again since 1.2); however, if you are experiencing weirdness try editing the assert_rjs method in arts/lib/arts.rb as described above.

This entry was posted on Thursday, January 18th, 2007 at 11:07 am and is filed under Ruby on Rails and Software Development, Writing Reliable, Bug-Free Code. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “ARTS and Rails 1.2”

  1. Baz Says:

    Kevin has updated his code, so a quick svn up should sort you out

Leave a Reply