I am new to RSpec and have just started to drive out my first view
using a spec. I have used the The RSpec Book (beta) to do the basic
stuff like testing for the presence of a field but I am unsure where
to start for driving out some AJAX functionality.
In the view, I will have a text field that a user can enter a name
into and then click on a link to check the availability of this name
or otherwise. I plan to implement the check as an AJAX request,
returning an HTML snippet or ‘available’ or ‘not available’.
I would appreciate some help on what sort of examples one might write
and the various mocks, stubs and helpers etc that can be used. Or
alternatively a pointer to some existing information/tutorials on this
topic.
I would appreciate some help on what sort of examples one might write
and the various mocks, stubs and helpers etc that can be used. Or
alternatively a pointer to some existing information/tutorials on this
topic.
For end to end coverage you’ll need to utilize something like Selenium
or Watir. Webrat has built-in Selenium support which I know folks are
using successfully (we are at MHS). It is not as polished as the
simulated support that Webrat has using an in-memory DOM, but that is
starting to change. Selenium and Webrat have a bright future ahead
(and a little longer term so does Watir IIRC).
For isolated and/or complex client-side logic in JS you can utilize a
JS-based testing framework like Screw.Unit or JSSpec:
Sorry I don’t have any links to any tutorials, maybe others can
provide. For me it was a largely dive-in and figure it out with
Selenium a few years back, and I personally haven’t taken the time to
dump what I’ve learned to the world. The RSpec Book will include a
chapter on automating Cucumber scenarios in the browser with Selenium,
although I know that chapter has not been released yet.