Capybara's save_and_open_page

33 views
Skip to first unread message

Matt Stenerson

unread,
Aug 10, 2013, 10:13:55 AM8/10/13
to rai...@googlegroups.com
Many times I've had issues with my tests failing while my app seemed to be working fine.  Maybe I'm the only one who didn't know about this method until this morning but it was certainly an "ah ha" moment for me.  Calling save_and_open_page within an it block will save the simulated page as it currently is and open it in your browser.  From there you can inspect the elements and see why your test is failing.  It would have saved me a lot of time to know this existed before today.

When getting started with all of this stuff it's pretty difficult to understand where one piece ends (like rspec) and another begins (Capybara, for instance).  This can make it hard to do proper Google searches for issues that you're having and can even make you miss things that are clearly spelled out in the doc (see link below).  I had done countless searches for "rspec debugging" but couldn't get the page source I was looking for until I stumbled upon this. 

Here are some additional resources:

Happy testing,
Matt
Reply all
Reply to author
Forward
0 new messages