Framework Design
A good test framework helps you manage your code so that maintenance is efficient and code is not duplicated.
Instead of having a single lengthy file of code, splitting the code into smaller files enables ease of reuse and upkeep.
The framework design that will work best with your web application will be dependent on the structure of your app, but the links below give a few organizational models to begin from.
Sample Frameworks
Example 1: Data Driven by YAML file by aidy dot lewis at googlemail dot com
This framework uses YAML for test data and XML for logging.
browser.rb, home.rb, login.rb, register.rb - files that hold object actions and methods generally relating to individual HTML pages
utilities.rb - a module that holds an XML logger class
demo_test.rb - reads the YAML test data
test_data.yaml - holds the test data
test_run.rb - this is the script that runs the tests
a full description lies here: http://agiletester.co.uk
watir_framework.zip
Example 2: AccountExample
This sample compares data between two databases and also uses a spreadsheet to manage the test data.
ExampleHarness.rb - the main file that retrieves the data and runs the individual tests
TestData.xls - the spreadsheet that holds the data used for the tests
LogInOut.rb - the login and logout methods contained in one file
CreateAccounts.rb - creates unique accounts within the application
DataVerification.rb - connects to both a MSSQL and Oracle database to compare and verify data (our application uses Oracle, but then moves data into MSSQL for other applications to access)
AccountExample.zip
Example 3: Defining your Watir test cases in a Confluence Wiki Page
See full details about how to do this at http://watirmelon.wordpress.com/2008/04/13/watir-tests-from-wiki-page/
Example 4: Rasta - a FIT influenced keyword driven framework
http://rasta.rubyforge.org
Further Reading:
Grow Your Test Harness Naturally
by Kevin Lawrence in stickyminds.com, March 2005
How to start writing web test scripts with Ruby and Watir
by Jim Matthews, October 2007