我们正在从webrat迁移rails集成测试到capybara。将response.should
替换为response.body.should
。还将require 'capybara/rails'
添加到spec_helper.rb。但是有一个错误说undefined method 'visit'
。每个visit
都会导致错误。这是导致错误的前两段代码:
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
之前的循环只是为下面的rspec案例登录系统。水豚代码有什么问题?谢谢你的帮助。