Download Selenium Server locally - set up a script or alias for it, to make things easier, as you'll need to run it whenever you run tests.
On your server, install rvm. Use it to install the most recent version of ruby, which will come with rubygems.
Install gems:
gem install selenium-webdriver
gem install rspec
gem install mysql
Now, add some lines to your test file (along with gem requires). Bold text should be filled in with your details.
gem install rspec
gem install mysql
driver = Selenium::WebDriver.for :remote, :url => "http://localhost:port/wd/hub", :desired_capabilities => :chrome
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
dbh = Mysql.real_connect(address, user, password, database)
You can use "wait" later to wait for particular events (like "wait.until { driver.find_element(:class => something) }"). The timeout is how long it'll wait in seconds.wait = Selenium::WebDriver::Wait.new(:timeout => 10)
dbh = Mysql.real_connect(address, user, password, database)
The "dbh" variable you set to your mysql connection can be used for running sql queries, though it'll return a query object which you'll need to parse to make meaningful.
You'll need to download ChromeDriver and extract it into where the Selenium Server is located, if you want to test using Chrome (pro-tip: set up a config file and have configs for every major browser, if you're serious about testing).
If everything's working properly, you should be able to automate browser functions (by running rspec tests in your virtual machine using a remote shell), which will allow you to automate server SQL querying to validate changes to the database. The tests should just be rspec assertions based on SQL query results. Even nicer, you should be able to set up Growl locally if you're running OSX (might try this next - I've used it for Ruby on Rails rspec tests and it's pretty cool).