It’s time for something new

After 14 years we’re hanging up our keyboards. Our team is joining the lovely people at Culture Amp, where we’ll be helping build a better world of work.


Taking the pain out of save_and_open_page

By Tim Riley23 Mar 2011

At Icelab we’ve been working for a while on a number of Ruby on Rails apps, but so far I’ve been remiss in sharing what I learn as I go about the development work. Time to change that. Let’s start with something very simple, but a big time-saver.

Most of our app testing these days is done using the Capybara DSL directly within RSpec request/ingtegration specs (see this post for a good introduction to the technique). Since these tests run the app through a simulated browser, it is useful for debugging to run the save_and_open_page method, which takes a snapshot of the current page and opens it in your own running browser.

As useful as the method is, it is laborious to type. Let’s fix that. Create a spec/support/requests.rb file and add the following:

def page!

Now all you need to type is page!: a small change, but with big effect. Keep your eyes open for ways like this to reduce the friction in your testing, and you’ll end up with much more time to focus on your app and the business value at hand.