Rails 3.2 capybara Capybara :: ElementNotFound: Unable to find xpath "/ html"

I am trying to test a rails application using rspec 2.10.0 + capybara 1.1.2. Here is my test file

require 'spec_helper'

    describe AdminPanelController do
      describe "index" do
        it "should have return code 200" do
          visit '/admin'
          page.should have_content "hello"
          #response.status.should be(200)
        end
      end
    end

And here is the test result

 Failure/Error: page.should have_content "hello"
 Capybara::ElementNotFound:
   Unable to find xpath "/html"

I google about this problem, but I find only information that webrat may be a problem, but I do not have this gem. Thanks for any suggestions.

+5
source share
1 answer

Invalid test type. This is similar to a controller test that runs tests using methods like get and post, and is located in the spec / controllers folder. Query specifications that use capybara are in the specification / queries. Run $ rails generate scaffold SomeModelto see how they look.

, capybara , :

describe AdminPanelController, :type => :request do
  ...
end
+14

All Articles