The release of RSpec 0.9.4 can be considered a landmark release of sorts. With the inclusion of Spec::Ui 0.2.0, RSpec can now perform functional testing of web applications within a browser. Out of the box support
is limited to Watir/Internet Explorer for now as the Selenium RC custom matchers are not implemented yet. includes WATIR/Windows and Watirsafari/OSX. The custom matchers for Selenium RC are not implemented yet but its certainly possible to use Selenium with Spec::Ui, it just won’t read as nicely compared to WATIR. Spec::Ui also comes with a custom result formatter that packages a screenshot of the browser on spec failure, along with its HTML source in the report.
To use Watirsafari in your functional specs, you’ll need to install the gem for it: gem install watirsafari
spec_helper.rb should be updated to include the snippet below (code lifted from the original release announcement):
Spec::Runner.configure do |config|
The specification will need before and after blocks like this:
@browser = Watir::Browser.new
# This is needed to make screenshots work
Spec::Ui::ScreenshotFormatter.browser = @browser
@browser.kill! rescue nil
There are a lot more useful information available in the examples supplied with Spec::Ui. Take a look at the samples to get up and running.
My thanks to Aslak Hellesoy for correcting me on support for WATIR and Selenium.