Bill Atkins wrote:
> I'm writing a web app in Ruby that I'd like to be able to unit-test. 
> The application is a webmail system that requires the client to
> support cookies.  Is there any recommended way of doing this?

I have an approach, acquired by stealing what seemed to be the best 
ideas floated here and elsewhere.  YMMV, etc.

Generally, I try to push the presentation layer out as far as I can. 
Ideally, the core of the application should work just as well as a 
command-line program or a set of Web services.  Therefore (or so goes 
the theory), by the time you get to testing the graphic interface, 
you're past testing whether code emits correct values when given 
assorted input.  Now you want to see that the values are correctly 
populating some UI, and the UI is correctly triggering some events.

One way to do this is to write the app to exchange XML or some other 
form of presentational-neutral text.  Unit tests for the application 
proper can then use regexen or whatever to verify the resulting strings.

Testing the actual Web  browser part is harder, because of the 
differences among browsers.  I've been using the CIEController lib [0] 
to drive Internet Explorer from Ruby.  I am not aware of anything 
similar for Mozilla.  But it helps verify some coarse-grained behavior.

I still end up having to do a fair amount of visual inspection and 
manual clicking with assorted browsers; not sure how to get around that 
part.  But I try to put that off until I'm reasonably sure the server 
code is behaving correctly, independent of the browser.

James


[0] http://www.clabs.org/wtr/index.cgi?page=/AboutWtr