def execute_test(user_opts={}) opts = {:browser => :opera, :port => 4001, :db_setup_cmd => "rake db:automigrate MERB_ENV=test", :web_server_cmd => "merb --port 4001 -e test", :test_suite_url => "http://localhost:4001/selenium/core/TestRunner.html?test=..%2Fbubugtestsuite%2FTestSuite.html&auto=on&close=off&resultsUrl=%2Ftest%2FpostResults"}.merge(user_opts) # Setup the database puts opts[:db_setup_cmd] system opts[:db_setup_cmd] # Execute the web server in another process, execute the browser in the # current one, and when finished, kill the server process pid = fork { puts opts[:web_server_cmd] system opts[:web_server_cmd] } sleep 3 # Give the web server enough time to start opera_profile_dir = "test/opera-profile" cmd = "opera -pd #{opera_profile_dir} -nosession '#{opts[:test_suite_url]}'" puts cmd system cmd puts "Killing web server" Process.kill "KILL", pid Process.wait end execute_test