Undefined Method 'visit' after migrating to capybara from webrat in rails 3.2.12

209 views Asked by At

We are migrating rails integration test to capybara from webrat. Replace response.should with response.body.should. Also added require 'capybara/rails' to spec_helper.rb. However there is an error saying undefined method 'visit'. Every visit causes an error. Here is the first 2 piece of code which causes error:

describe "TestPaths" do
  describe "GET /customerx_test_paths" do
    before(:each) do
      ul = FactoryGirl.build(:user_level, :sys_user_group_id => ug.id)
      u = FactoryGirl.create(:user, :user_levels => [ul], :login => 'thistest', :password => 'password', :password_confirmation => 'password')
      visit 'authentify/'
      fill_in "login", :with => u.login
      fill_in "password", :with => 'password'
      click_button  
    end

    #customer status category
    it "should display customer status category index page" do
      visit customer_status_categories_path
      response.body.should have_selector("title", :content => "Customerx")
    end

...
end

The before loop is just login to the system for the rspec case below. What's wrong with the capybara code? Thanks for help.

0

There are 0 answers