I am using merb with rspec and webrat. How to ensure that rjs template was successfully rendered? I cannot just write have_xpath because of ajax.
Well, I got it. There are selenium, watir and friends. Sounds weird because I need a browser for testing :(
This is not easy. You already mention selenium, which will test from the browser all the way down, but it is slow. My suggestion is to break this into a couple parts. First use rspec to check the output of both the original page request to make sure it has the JavaScript you think it does, and also the ajax response to ensure that it is being served correctly.
Now the trick is to test the JavaScript itself. There are a number of testing libraries for JavaScript. I suggest jUnit. write tests just like you would for rspec and test the function of your ajax request, and the resultant rjs separately.
Finally use selenium to run the full stack and prove everything works together. If there are bugs go back to one of your unit test and write a simpler test that will expose the bug.