Enough Planning! Now Rush to Coding...

You could add the following project to any Rails web site. I created a new one with rails yarWiki, then I opened the file config/database.yml and set all the databases to sqlite3. That just shuts ActiveRecord up. This project won't use the database. (If you don't have any Rails projects yet, read another tutorial to get started, and come back here when you know how to work with a Rails site.)

Install two plug-ins, FormTestHelper and ARTS. Plug them in like this:

script/plugin install -x http://form-test-helper.googlecode.com/svn/form_test_helper/
script/plugin install -x http://thar.be/svn/projects/plugins/arts/

They provide select_form and assert_rjs, respectively, to test FORMS and Remote JavaScript (JavaScriptGenerator). Using the vocabulary developed earlier, we could say these assertions attack legacy HTML and JavaScript situations.

Now start the server by opening another command-line shell and entering this:

script/server -p 3000

Our experiments will assume that server is always running and available on port 3000. Now generate the skeleton for our project:

script/generate controller wiki

That creates a controller and its test suite, producing this familiar output:

./app/controllers/wiki_controller.rb
./app/helpers/wiki_helper.rb
./app/views/wiki
./test/functional/wiki_controller_test.rb

Now we start with a test. The Rails test framework might indeed be exemplary, but this Short Cut is about what happens when we move beyond its built-in features. ...

Get Test Driven Ajax (on Rails) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.