Automatic functional testing for ajax?

Michael Schuerig
Fri, 16 Sep 2005 00:56:08 -0000

I''ve found that I sometimes forget to provide an action for handling an
ajax request. Of course the problem immediately becomes apparent, when
I do something to the user interface that triggers the ajax request.
The problem is that I have to do it manually. I''d feel better if I had
an automatic way to check that required controllers/actions do exist.

My current idea is as follows:
(1) Forget about the general case, consider only ajax requests related
to specific helper methods.
(2) Redefine these helper methods in a sandbox environment to write test
methods.
(3) Render all views and collect the test methods.

I''m not sure whether this approach is workable. Redefining the helper
methods to do something different, is probably no big deal. The
scaffold generator uses this technique to write ERb/Rails source code
instead of HTML.

The catch is (3). What I don''t yet see is how to more or less neuter
everything apart from the methods I''m interested in. In a tool, I
can''t
provide the same environment for the views that they get when rendered
from a controller. Rampant use of method_missing and const_missing come
to mind, still I doubt this is enough.

Ideas? Suggestions? I appreciate your comments.

Michael

--
Michael Schuerig                           The more it stays the same,
mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org
The less it changes!
http://www.schuerig.de/michael/      --Spinal Tap, The Majesty of Rock