Capybaras eating cucumbers
(or, testing static sites with Cucumber and Capybara)
While working on an app built purely in HTML and Javascript, we needed a good way to write integration tests. We played around with a few different approaches, including “functional” tests using one of the Javascript unit testing libraries. But for now, we settled on using Selenium.
OMG you’re crazy!
No, we’re not. The latest version of Cucumber comes with capybara, which makes it super simple to use Selenium. Capybara just uses any rack app, so we made a simple rack app that serves our static files. So here is what we ended up with in features/support/env.rb
:
Now just copy over the web_steps.rb that cucumber generates from another project, and proceed as normal.