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)
end
end
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.
1 comment:
Kevin has updated his code, so a quick svn up should sort you out
Post a Comment