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! save_and_open_page end
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.