0

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.

user938363
  • 9,990
  • 38
  • 137
  • 303
  • Can you paste spec_helper.rb? – Benjamin Sullivan Mar 02 '13 at 04:56
  • require 'rspec/rails' require 'capybara/rails' require 'rspec/autorun' require "factory_girl_rails" – user938363 Mar 02 '13 at 05:14
  • We moved all the 'visit' .. into 'it' loop and 'visit' is still not defined. – user938363 Mar 02 '13 at 05:15
  • 1
    Where the test is located? Guess somewhere in 'requests' directory? – dimuch Mar 02 '13 at 05:21
  • Are you requiring spec_helper in your spec file? (Also `before` and `it` are called blocks, not loops.) – Benjamin Sullivan Mar 02 '13 at 05:31
  • The tests is in requests directory. After moving to features subdir, the visit became defined and the error disappears (undefined method 'visit'. Got other errosr though) after moving to features. The rails g integration_test creates requests subdir instead. It seems that we have to manually create the features subdir for capybara everytime. – user938363 Mar 02 '13 at 19:43

0 Answers0