Skip to content

Instantly share code, notes, and snippets.

@justinwiley
Created August 31, 2011 18:48
Show Gist options
  • Save justinwiley/1184354 to your computer and use it in GitHub Desktop.
Save justinwiley/1184354 to your computer and use it in GitHub Desktop.
Integrating Cucumber Capybara Smoketest with Capistrano
@test_deploy @javascript # @test_deploy tag setup in cucumber.yml profile, @javascript runs in capybara-webkit
Feature: Smoke Test
In order to test that the application is deployed
As a caring developer
I want to check a few features of the site
Background:
Given we are in the deploy environment
Scenario: Logging in and checking basic navigation
When I go to the home page
Then I should see "Welcome"
And I should see most recent revision
When I follow "Sign in"
And I fill in "Email" with "[email protected]"
And I fill in "Password" with "h6$reymmeErt2"
And I press "Sign in"
Then I should see "Signed in successfully."
# note DEPLOY_ENVIRONMENT environment variable
test_deploy: --tags @test_deploy --format pretty DEPLOY_ENVIRONMENT=true
after "deploy:restart", :do_smoke_test
task :do_smoke_test do
puts `bundle exec cucumber features/ -p test_deploy` # would be nicer output with p3open
end
Given /^we are in the deploy environment/ do
pending unless ENV['DEPLOY_ENVIRONMENT'] # another check to prevent this from executing during our normal test runs
# Set capybara config to execute against remote environment
# In my case I'm using the amazing capybara-webkit gem. This is actually in env.rb for me, your mileage may vary
# Note: Default driver will not execute remote sites
Capybara.javascript_driver = :webkit
Capybara.run_server = false
Capybara.app_host = "http://example.com" # point to remote server we will test
end
# Contents of cap REVISION is included in my views, test to ensure we've really deployed the latest
Then /^I should see most recent revision$/ do
revision = `git ls-remote | head -n 1`.split[0]
page.should have_content(revision)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment