Webrat
From Docunext Technology Wiki
An example webrat suite of tests from Regdel (though not used anymore):
require File.join(File.dirname(__FILE__), '..', 'regdel.rb')
require 'rubygems'
require 'rack/test'
require 'spec'
require 'spec/autorun'
require 'spec/interop/test'
require "webrat"
require "test/unit"
Webrat.configure do |config|
config.mode = :rack
end
class RegdelTest < Test::Unit::TestCase
include Rack::Test::Methods
include Webrat::Methods
include Webrat::Matchers
def app
@app ||= Regdel.new('')
end
def test_it_works
visit "/"
click_link("Home")
assert_have_selector("#ft")
click_link("Ledger")
assert_have_selector("#ft")
click_link("New Entry")
assert_have_selector("#ft")
click_link("New Account")
assert_have_selector("#ft")
click_link("Accounts")
assert_have_selector("#ft")
end
def test_the_app
visit "/ledger"
assert_have_selector("#ft")
end
def test_new_account
visit "/account/new"
assert_have_selector(".form-table")
assert_have_selector("#ft")
end
def test_new_account_public
visit "/s/xhtml/account_form.html"
assert_have_selector(".form-table")
assert_have_selector("#ft")
end
def test_new_entry
visit "/s/xhtml/entry_all_form.html"
assert_have_selector("#memorandum")
assert_have_selector("#ft")
end
end