View The Space is Hiring

Thursday, December 1, 2011

Running your still alive recipe as part of your build

For those of you not familiar with StillAlive, it's an awesome platform that monitors your web site using custom Gherkin recipes. Those comfortable with cucumber will be right at home with StillAlive as the recipes give you almost exactly what comes with the controversial web_steps.rb. The end result is that instead of simply pinging a page and getting back success or failure, StillAlive allows you to actually exercise the full stack of your application up to once a minute.

We started using StillAllive last month. One limitation with StillAlive and other intelligent monitoring solutions is that as your application changes with each deployment, your StillAlive monitoring recipe can break becoming incompatible with the latest version of your app. Our solution to this issue is including our StillAlive recipes as part of our cucumber suite. In this case our still_alive.feature file looks like:

Feature: Still alive user with spaces
In order to get alerts
As a vts employee
I want still alive to click through pages and let me know if everything is ok
Background:
Given I am a user with email: "user@test.com", password: "password"
And I have 3 spaces
And I have 2 tour books with 2 spaces each
And there are featured spaces
Scenario: Click around the site
And I go to http://www.ourapp.com/users/sign_in
And I fill in "user_email" with "user@test.com"
And I fill in "user_password" with "password"
And I press "Sign in"
And I follow "View Space" within "li.myspace_1"
And I should see "Space Details" within "title"
And I follow "dashboard" within "#navigation"
And I follow "View Space" within "#spaces .last"
And I should see "Space Details" within "title"
And I follow "dashboard" within "#navigation"
And I follow "Show Tour Book" within ".tour_book_1"
And I should see "Tour Book" within "title"
And I follow "dashboard" within "#navigation"
And I follow "Show Tour Book" within "#tour_book_items .last"
And I should see "Tour Book" within "title"
And I follow "View Space" within ".tour_book_space_1"
Then I should see "Space Details" within "title"
And I follow "dashboard" within "#navigation"
And I follow "View Space" within ".featured_space_1"
And I should see "Space Details" within "title"
And I follow "dashboard" within "#navigation"
And I follow "View Space" within "#featured_spaces .last"
And I should see "Space Details" within "title"
And I follow "my portfolio" within "#navigation"
Then I should see "My Portfolio" within "title"
And I follow "View Space" within ".myspace_2"
Then I should see "Space Details" within "title"
And I follow "dashboard" within "#navigation"
And I follow "Edit" within ".myspace_3"
Then I should see "Edit Space" within "h1"
And I follow "my portfolio" within "#navigation"
And I follow "Tour Books" within "#subnavigation"
And I follow "Edit" within "li.last"
And I should see "Edit Tour Book" within "title"
And I follow "Advanced Search"
And I should see "Search" within "title"
And I follow "View Space" within ".search-result4"
And I should see "Space Details" within "title"


Since we are being naughty and still using web_steps.rb, we just needed to add the following to our paths.rb which converts the absolute url http://www.ourapp.com/users/sign_in to the relative /users/sign_in for testing within cucumber.

when %r{(?:http://www.ourapp.com|^)(/.*)}
$1
view raw path.rb hosted with ❤ by GitHub


Once that test worked within our cucumber suite, we copied everything but the Background to our StillAlive recipe.

Now if something we change in development is incompatible with our StillAlive recipe, we'll find out about it before we release to production.

No comments:

Post a Comment