0
votes

When working with Capybara and Rspec in my features spec, after calling "visit", page.body returns: "<html><head></head><body></body></html>" This, of course, causes all my "find"s to fail, as there is nothing there. save_and_open_page care of launchy shows me the complete, accurate page, chock full of HTML tags.

Any thoughts on why Capybara is not setting the page element correctly?

2

2 Answers

0
votes

turns out this was due to a conflict between webrat and capybara. Diving into the source for where "visit" and "page" are referenced, I discovered that visit is declared in both Webrat and Capybara; however, the effect of "visit" in each differs. Capybara sets the page variable, while webrat sets a response variable. I don't yet know enough about how to use both of them, as they seem to both be useful for different purposes - if anyone wants to leave some comments with some resources I certainly would appreciate it!

0
votes

I was getting this too. When I puts out the markup from the visit call, I found that the page was actually throwing a 404, but I wasn't getting a Capybara 404 error.

If you run something like the following, it will print out the markup so you can debug more easily:

When /^I view the front page$/ do
  @visit = get "#{host}/frontpage"
  puts @visit
end

Hope that helps someone.