bakineggs

least surprising surprise

My name is Dan Barry. I'm a senior in Computer Science at The University of Illinois at Urbana-Champaign.

I've been programming for over ten years now. Most recently, I've been programming in Ruby and using the Rails framework. I'm also proficient in PHP and JavaScript.

I'm currently living in San Francisco, California where I am an intern at Scribd.

Blog

May 1, 2010 @ 11:48pm

Testing AJAX with Cucumber and Capybara

For a recent project, I used Cucumber and Capybara for my user stories. When I decided to AJAXify the functionality, I wrote some stories tagged with @javascript that were nearly identical to my non-javascript versions (non-JS and JS). Since the changes to the page content should be the same with or without Javascript, testing the page content wouldn't actually verify that the AJAX funtionality was working. To solve this, I created the step "Then the page should not change" with the following definition:

Then 'the page should not change again' do
  evaluate_script('window.onunload = window.stop')
end

Now, if the user clicks a link that doesn't have its behavior overwritten by Javascript, a blank page will be displayed and any following steps will fail.

Post Comment

© 2008-2010 Dan Barry. Designed by Hunter Hastings.