|
Red Squirrel Reflections
Dave Hoover explores the psychology of software development
|
|
Thu, 21 Sep 2006If you've ever wanted to_bool in Ruby
class Object
def to_bool
!!self
end
end
Watir on Rails Update: It's all Relative I made a backward compatible update to the Watir on Rails plugin to allow you to get rid of those nasty fully-qualified URLs in your Watir on Rails tests. To allow for this, I added some config-like class methods to specify the server and port (defaults to http://localhost:3000) in your TestCases. Here's a simple example, relying on the defaults:
class WelcomeTest < Test::Unit::TestCase
include WatirOnRails
def test_salutation
browser = open_browser
browser.goto("/")
assert_match /Welcome Guest/, browser.div(:id, "banner").text
end
end
A slightly more complex example, testing against a non-standard test server configuration:
class MyAccountTest < Test::Unit::TestCase
include WatirOnRails
server "10.2.4.143"
port 3001
def test_update_preference
browser = open_browser("/squirrels/")
browser.link(:text, /preferences/i).click
browser.text_field(:name, "user").set("dave")
browser.text_field(:name, "pass").set("test")
browser.button(:name, "commit").click
assert_match /<h2>Welcome Dave<\/h2>/, browser.html
browser.checkbox(:id, "largeFont").set
browser.button(:name, "commit").click
assert_match /<h1>Welcome Dave<\/h1>/, browser.html
end
end
If you're serious about building up a good Watir acceptance test suite, consider developing a site-specific lanaguage (example here).
|