[rspec-devel] [ANN] RSpec 0.9.4

aslak hellesoy aslak.hellesoy at gmail.com
Thu May 10 06:57:50 EDT 2007

RSpec 0.9.4 has just been released. Gems haven't rsync'ed around the
globe yet, so you might have to wait a few hours to install it.

The big news this time is Spec::Ui 0.2.0, which has been released
along with RSpec core. This RSpec extension gives you custom Watir
matchers (custom Selenium-RC matchers are not implemented yet).
Moreover, it comes with a custom KICK ASS formatter that, for each
failing example, puts a screenshot of your browser - and its HTML
source - straight into the report. And it all gets embedded into one
single HTML file.

Spec::Ui is not documented on the website yet (there are some READMEs
and examples in the source though). But here is the gist of it:

== Install ==
gem install rspec -r 0.9.4
gem install spec_ui -r 0.2.0

=== Windows users - if you want screenshots ===
gem install win32screenshot
Install RMagick (special install procedure)

== Configure ==

=== Rakefile ===
require 'spec/rake/spectask'

desc "Run UI Specs"
Spec::Rake::SpecTask.new('spec:ui') do |t|
  t.spec_files = FileList['spec/**/*.rb']
  t.spec_opts = [
    '--require', 'spec/spec_helper',
    '--format', 'Spec::Ui::ScreenshotFormatter:spec_report.html',
    '--format', 'progress',

=== spec_helper.rb ===
# require this file from all your specs under MYAPP/spec/watir or
require 'rubygems'
require 'spec'
require 'spec/ui'
require 'spec/ui/watir'

class Spec::DSL::Behaviour
  def before_eval
    # This gives us Watir matchers. Sorry - Selenium-RC users must use
the low level API
    include Spec::Matchers::Watir

=== before and after blocks ===
All of your specs need some carefully designed before and after blocks:

before(:all) do
  @browser = Watir::Browser.new
  #@browser = Selenium::SeleniumDriver.new("localhost", 4444,
"*safari", "http://www.google.no", 10000)

after(:each) do
  # This is needed to make screenshots work
  Spec::Ui::ScreenshotFormatter.browser = @browser

after(:all) do
  @browser.kill! rescue nil

More information about the rspec-devel mailing list