jnicklas/capybara — Issue #633: Testing a site located in a subdirectory
Author: mattconnolly
Created: 2012-02-04 11:21:56+00:00
State: open

Hi, I'm testing a PHP application in a subdirectory with Capybara. The local test site is in a sub-directory, for example: http://localhost/myapp

The login form action is "/myapp/login", which works perfectly from the browser.

However, when I test with `Capybara.app_host = "http://localhost/myapp"` then Capybara correctly loads the home page, but when I submit the login form it submits to: http://localhost/myapp/myapp/login which is a straight concatenation of the two strings. The form action starting with a leading slash should be taken from the root of the server (unless there's a BASE tag in the head... not sure I want to think about that just this second).

All of my uses of `visit "/some/page"` work as expected because my test code is referencing that URL relative to the app_host setting. But links followed on the site cause problems with the duplicated directory name as above.

Is this a bug in Capybara? Or am I simply missing some configuration setting?