Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put capybara output html to a specific folder?

When I use the "Show me the page" step, with Capybara / Cucumber, can I control where the files get output? I can't seem to find the config for this, and my google fu is failing me.

Right now it appears that by default they go to the root of my rails folder and clutter up things there.

like image 460
Dave Sanders Avatar asked Aug 04 '10 13:08

Dave Sanders


2 Answers

There is indeed a config option that allows you to specify where to output the files:

Capybara.save_and_open_page_path

I believe it was added in the latest version (0.3.9)

In your env.rb file you can do something like:

Capybara.save_and_open_page_path = '/Users/jsboulanger/my-rails-project/tmp'

In Capybara 2.10, Capybara::save_and_open_page= is deprecated. Instead, call Capybara::save_path=

like image 102
jsboulanger Avatar answered Nov 15 '22 19:11

jsboulanger


Nice. Thanks for this.

To be really neat about it I added the config line to config/environments/test.rb, since you generally only use capybara in test, and that works fine.

Since there's a bunch of subfolders in tmp/ I used:

Capybara.save_and_open_page_path = 'tmp/capybara'

and created that folder.

like image 34
jim Avatar answered Nov 15 '22 21:11

jim