1
我在Rails上编写测试方面有点新,我正在跟着RoR教程。我试图添加我自己的测试实用程序方法sign_up,类似于utility.rb中已有的sign_in方法。当调用它对着我的注册页面,不过,我得到这个错误:调用utility_rb中的sign_up实用程序测试方法失败
2) User pages index pagination as an admin user to unlock new users
Failure/Error: sign_up user
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'Name' found
# (eval):2:in `fill_in'
# ./spec/support/utilities.rb:33:in `sign_up'
# ./spec/requests/user_pages_spec.rb:63:in `block (5 levels) in <top (required)>'
我sign_up方法是这样的:
def sign_up(user)
visit signup_path
fill_in "Name", with: user.name
fill_in "Email", with: user.email
fill_in "Password", with: user.password
fill_in "Confirmation", with: user.password
click_button "Sign up"
end
它似乎开始出问题甚至只是逛signup_path - 我甚至不确定它会去那里。此外,如果我将fill_in "Name"
行注释掉,它将以相同的方式扼住fill_in "Email"
行。
关于这里发生了什么的任何建议或想法将不胜感激。
感谢, -Matt