Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara's save_and_open_page with absolute paths for stylesheets and javascripts

I'm using rspec features with capybara for testing my rails 3.1 application. Sometimes it's useful to save the static html of a page we're breaking on and have a glance on it. That what the save_and_open_page method is for.

But capybara generates an html file in a directory called tmp/capybara, so if my paths for stylesheets and javascripts look like this:

<script src="/javascripts/application.js?1362462583" type="text/javascript"></script>

they won't be found, because this absolute path assumes we're in a /public directory.

What is the best solution to save a page and open it properly?

like image 888
installero Avatar asked Jan 19 '26 11:01

installero


1 Answers

Asset pipeline support for save_and_open_page will be available in Capybara v2.1, see https://github.com/jnicklas/capybara/pull/958

In the meantime you have to use the selenium driver and halt the test execution using methods sleep gets or binding.pry so that you can interact with the selenium browser

like image 53
Arctodus Avatar answered Jan 21 '26 03:01

Arctodus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!