Home arrow Ruby-on-Rails arrow Page 2 - Acceptance Testing

Acceptance Testing

If you've built a complicated application and you want to make sure it works, you perform acceptance testing. This three-part article series will show you how to automate the process. It is excerpted from chapter 11 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
July 23, 2010
  1. · Acceptance Testing
  2. · Installing Selenium
  3. · Writing Selenium Tests
  4. · Action Commands

print this article

Acceptance Testing - Installing Selenium
(Page 2 of 4 )

Before installing the plugin, you need to install Selenium itself, as follows:

$ sudo gem install selenium

Attempting local installation of 'selenium' Local gem file not found: selenium*.gem Attempting remote installation of 'selenium' Updating Gem source index for: http://gems.rubyforge.org
Successfully installed selenium-0.7

Note  The RubyGems repository might not contain the latest version. If you want the latest version of Selenium, download Selenium Core from http://www.openqa.org/selenium-core and extract it to vendor/selenium.

The Selenese format uses the Textile markup format (introduced in Chapter 3), which requires that you have RedCloth installed on your machine. To verify that you have RedCloth installed, execute the following command:

$ gem list

RedCloth (3.0.4)
    RedCloth is a module for using Textile and Markdown in Ruby. Textile
    and Markdown are text formats. A very simple text format. Another
    stab at making readable text that can be converted to HTML.

If you don't see RedCloth in the list of installed RubyGem packages, execute the following command:

$ sudo gem install redcloth

Next, install the Selenium plugin directly from the Subversion repository:

$ script/plugin install http://svn.openqa.org/svn/selenium-on-rails/

This installs the latest version of the plugin in the vendor/plugins/selenium-on-rails directory. Execute the rake command in the plugin directory to verify that the installation works:

$ cd vendor/plugins/selenium_on_rails
$ rake

The rake script executes all tests. You should see them pass without errors.

Note  On Windows, if you want to use rake to run your acceptance tests, you need to install win32open3. See the Selenium on Rails homepage (http://www.openqa.org/selenium-on-rails/) for details.

When using Selenium Core, you start the acceptance tests by opening the Selenium test runner in your browser and executing the Selenium test suite. With Selenium on Rails, these steps have been automated and can all be executed with the following command:

$ cd /home/projects/george/emporium
$ rake test:acceptance

If you execute the command now, Selenium on Rails will complain that you haven't specified the path to the browser executables. To specify the path, you need to modify the Selenium on Rails configuration file (vendor/plugins/selenium_on_rails/config.yml). The configuration file allows you to specify where browser executables are located on your system and the environments for which Selenium should be enabled. Create the configuration by renaming vendor/plugins/selenium_on_rails/config.yml. example to config.yml. Update the paths to match your system's configuration, as in the example shown here:

# Enable Selenium for the following environments
- test
#  - development
#  - production

# Paths to browsers
  safari: '/Applications/Safari.app/Contents/MacOS/Safari'
  firefox: /usr/bin/firefox
  ie: 'c:\Program Files\Internet Explorer\iexplore.exe'

Tip  Selenium on Rails runs the acceptance tests in all browsers that have been listed in the configuration file. This makes it easy to test that your application works on multiple browsers. Selenium supports most browsers and platforms, including Windows, Mac OS X, and Linux. Check the Selenium documentation (http://www.openqa.org/selenium-core) to verify that your setup is supported.

Selenium and Selenium on Rails are now installed, which means you can start writing Selenium tests.

blog comments powered by Disqus

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials