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