public
Description: Cucumber extension that uses Webkit to capture PNG screenshots of your web application during tests
Homepage:
Clone URL: git://github.com/mocoso/cucumber-screenshot.git
name age message
file .gitignore Sun Oct 18 12:30:13 -0700 2009 Initial commit [mocoso]
file MIT-LICENSE Sun Oct 18 12:30:13 -0700 2009 Initial commit [mocoso]
file README.rdoc Sun Nov 01 00:12:38 -0700 2009 Update code to be inserted into Rails project t... [mocoso]
file Rakefile Sun Nov 01 00:12:38 -0700 2009 Add homepage to gemspec [mocoso]
file VERSION.yml Sun Nov 01 00:20:33 -0700 2009 Bump patch number (to 0.2.1) [mocoso]
directory lib/ Sun Nov 01 00:20:33 -0700 2009 Bump patch number (to 0.2.1) [mocoso]
directory spec/ Sun Nov 01 00:12:28 -0700 2009 Upgrade to Cucumber 0.4.3 And replace #embed_i... [mocoso]
README.rdoc

Cucumber Screenshot

Cucumber Screenshot makes it easy to capture screenshots of the pages generated by your Rails application as it runs your Cucumber/Webrat features.

It uses WebKit to generate the screenshots and so is only available for OS X.

If you want to take screenshots on any other platform then take a look at [this example]github.com/aslakhellesoy/cucumber/blob/master/examples/watir/features/support/screenshots.rb from Cucumber.

Requirements

A Rails application with some features written in Cucumber/Webrat.

Install

To install the latest release as a gem

  sudo gem install cucumber-screenshot

Use

Create a cucumber_screenshot_env.rb file in the ./features/support/ directory in your Rails project and put the following in it.

  begin
    require 'cucumber_screenshot'
    World(CucumberScreenshot::World)

    After do |scenario|
      if scenario.failed?
        screenshot
      end
    end

    AfterStep('@screenshot') do |scenario|
      if screenshot_due?
        screenshot
      end
    end
  rescue Exception => e
    puts "Snapshots not available for this environment. Try installing
      cucumber-screenshot with\n\n  gem install cucumber-screenshot\n"
  end

Then use the ‘rake cucumber’ and ‘rake cucumber:wip’ tasks as per usual.

Screenshots will be captured for every step failure and for every step in scenarios tagged @screenshot. The screenshots will be saved to a ./features/screenshots/ directory in your project.

Capturing a single screenshot

If you want to capture a single screenshot rather than every page then add the following step to one of your Rails application’s step files

  Then "screenshot" do
    screenshot
  end

and then add

  Then screenshot

to your feature file in the place where you want to capture a screenshot of the page that your application generated.

TODO

  • Clean out existing snapshots before each run
  • Add support for tables
  • Add a Rails generator to add the env and step code to a project

License

Copyright © 2009 Joel Chippindale. See MIT-LICENSE.txt in this directory.