Reputation: 125892
I'm trying to write an Rspec request spec using Capybara. It seems that everything is working correctly except that Capybara sees the page as blank.
Good signs:
assert_select "h1", :text => "hello world"
, the test passes.Bad signs:
page.should have_content('hello world')
, it fails, saying Capybara::ElementNotFound: Unable to find xpath "/html"
$stdout.puts page.html
, it's empty except for a doctypeMy test looks something like this:
describe "working with foos" do
it "should have a 'new foo' form" do
get '/foos/new'
assert_select 'h1', text: 'hello world' # passes
page.should have_content('hello world') # fails
$stdout.puts page.html # empty except for a doctype
end
end
What could be wrong here?
Upvotes: 4
Views: 799
Reputation: 125892
... which I'm sharing to save others the same pain.
Capybara uses the visit
method to set up its page variable.
visit '/assembly/manage/task_lists/new'
Don't use get
with Capybara:
get '/assembly/manage/task_lists/new'
Upvotes: 7