Skip to content

Instantly share code, notes, and snippets.

@wheresalice
Created April 8, 2010 12:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wheresalice/360039 to your computer and use it in GitHub Desktop.
Save wheresalice/360039 to your computer and use it in GitHub Desktop.
Very basic test suite using Watir to ensure a Drupal site is working
#!/usr/bin/ruby1.9.1
require "rubygems"
require "test/unit"
require "watir"
$site = ARGV[0]
puts $site
if ($site[-1,1] != "/")
puts "url must end in a slash"
exit
end
class DrupalTests < Test::Unit::TestCase
def test_anonymous_cant_update
browser = Watir::Browser.start($site + "update.php")
assert_equal(browser.h2(:index, 1).text, "Access denied")
browser.close
end
def test_root_shouldnt_show_errors_or_warnings
browser = Watir::Browser.start($site)
number_errors = browser.contains_text("error:")
number_warnings = browser.contains_text("warning:")
assert(number_errors == nil)
assert(number_warnings == nil)
browser.close
end
def test_anonymous_cant_access_admin
browser = Watir::Browser.start($site + "admin")
access_denied = browser.contains_text("Access denied")
assert(access_denied > 0)
browser.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment