If you think writing test cases for PhantomJS is too close to the metal, then have a look at Casper.js (github.com/n1k0/casperjs) from Nicolas Perriault. Spend few minutes reading the documentation and you’ll agree that this will simplify your PhantomJS scripts by a huge margin.
An alternative approach is Ghostbuster (github.com/joshbuddy/ghostbuster), created by Joshua Hull. Again, there are several very useful convenience functions, in particular to emulate the user behavior as he steps through your web applications.
Capybara is a popular tool to test Ruby-based web applications. Integration of PhantomJS with Capybara has been requested (see issue #50). While waiting until this feature will be supported (if ever), one solution to run Capybara tests headlessly is by using Jonathan Leighton’s excellent Poltergeist (github.com/jonleighton/poltergeist), a PhantomJS driver for Capybara.
Pick Casper, GhostBuster, or Poltergeist or even all of them! “Trick or test?”