Aug 23, 2011

Use httparty with rspec and capybara

httparty can be a useful supplement to Capybara drivers for use in a Capybara test suite. Take the example of an rspec-based load test.

For this purpose Selenium’s WebDriver is too slow, rack-test doesn’t work remotely, and capybara-mechanize doesn’t work well with pages that rely on AJAX or JavaScript to create elements (although otherwise it’s quite well suited to this purpose).

Sometimes a good old-fashioned GET or POST is all you need. See the gist below for how to wire up a simple httparty example within your test suite. Admittedly, I didn’t roll this into an actual Capybara driver, though I might be interested in doing so if that’d be helpful for anyone.

Question or comment?