Capybara, save_and_open_page for the lazy!
- 1 minWhen I’m writting Rails integration tests with capybara, every once in a while there is something not working as I wish. When misfourtune occures, usually I want to see how my rendered page looks like save_and_open_page to the rescue!
Lets for the moment imagine that we are testing site navigation links. When Guest clicks on About navigation link, he/she should see About page.
After running test, it is failling
Hmm….that is strange! Lets see what my page looks like, just add save_and_open_page method call!
Capybara will open browser and render my current page. Sueprise….surprise, there is no about link rendered.
Thanks save_and_open_page you just save me a lot of the debugging!
Only thing that bugs me with save_and_open_page is size of method name, I’m just lazy typing it. It would be a lot nicer if I could just type page!.
Well… I could, lest write small Capybara extenstion and add it to spec/support directory.
Now I could just type page!