How do I get cucumber & capybara to use http:// paths instead of file:/// paths?
I'm using omniauth and cucumber with a new application. I've got omniauth up and working and am trying to add appropriate cucumber feature tests. I kept running into odd errors in testing - errors that I don't get when performing the same steps manually.
Via "show me the page" I've narrowed it down to the fact that when cucumber does anything it's doing it via a file path (e.g., file:///path/to/app/tmp/capybara/capybara-201107151148029152254898.html
) instead of an http path (e.g., http://localhost:3000/
).
Why would my cucumber tests go through file paths ins开发者_开发技巧tead of http paths; and how do I fix this situation?
I can only guess that Capybara implements "show me the page" as the following steps:
- Take the HTML source from the current page and write it into a file
- Open that HTML file
I assume your tests are hitting your application just fine using HTTP. (You can always verify that by looking at your logfiles.) But "show me the page" cannot simply open the URL it was testing because its content might change from request to request.
Example: A test posts a comment by POSTing to /comments
. If that fails for any reason and Capybara would open /comments
(the URL that raised the exception), it would issue a GET request and couldn't present you the content it saw.
精彩评论