I'm trying to write integration tests with Capybara, but every time the Selenium-controlled browser pops up, the page is blank. Furthermore, for a simple assertion like page.should have_selector('title')
, I get errors like
Failure/Error: page.should have_selector('title')
expected following output to contain a <title/> tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body></body>
</html>
I.e., the page is empty.
I'm visiting a path that's valid. If I do a save_and_open_page
, the page is there.
The relevant part of the Gemfile is
group :test, :development do
gem 'rspec-rails', '~> 2.4'
gem 'nokogiri'
gem 'webrat'
# capybara for javascript testing
gem 'capybara'
# launchy allows us to do save_and_launch_page, which is very helpful during testing
gem 'launchy'
end
The app is using Rails 3.1.1. I've done bundle install
and added
require 'capybara/rails'
require 'capybara/rspec'
to my spec_helper
.
Note, these are integration tests, not controller tests - I'm not missing render_views
.
I have other apps where this stuff works fine, which makes me think I'm either missing something in my config or there is an issue with the specific versions being used.
Selenium is trying to use Firefox, and I'm on OS X Snow Leopard, if that matters.
You might want to try removing webrat from your gemfile. I believe both webrat and capybara try to run the tests in the requests directory.