Ruby on Rails教程第10章清单10.36测试失败,因为它因练习9.6.5而不同
更新:已解决,恢复到运动前条件并将用户规格更改为“确认”而不是“密码确认”
describe "with valid information" do before do fill_in "Name", with: "Example User" fill_in "Email", with: "user@example.com" fill_in "Password", with: "foobar" fill_in "Confirmation", with: "foobar" end
任何做过这些练习的人都可以帮助我吗?
不幸的是,用户请求规范现在已经破坏,因为注册和编辑表单使用旧版本的错误消息部分。 要修复它们,我们将使用更通用的版本更新它们,如清单10.36和清单10.37所示。 (注意:如果您从第9.6节的练习中实现了代码清单9.50和代码清单9.51,那么您的代码会有所不同.Mutatat必需的修改。)
Failures: 1) User pages signup with valid information should create a user Failure/Error: fill_in "Name", with: "Example 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/requests/user_pages_spec.rb:104:in `block (4 levels) in ' 2) User pages signup with valid information after saving the user Failure/Error: fill_in "Name", with: "Example 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/requests/user_pages_spec.rb:104:in `block (4 levels) in ' 3) User pages signup with valid information after saving the user Failure/Error: fill_in "Name", with: "Example 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/requests/user_pages_spec.rb:104:in `block (4 levels) in ' 4) User pages signup with valid information after saving the user Failure/Error: fill_in "Name", with: "Example 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/requests/user_pages_spec.rb:104:in `block (4 levels) in ' 5) User pages edit with valid information Failure/Error: fill_in "Name", with: new_name 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/requests/user_pages_spec.rb:150:in `block (4 levels) in ' 6) User pages edit with valid information Failure/Error: fill_in "Name", with: new_name 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/requests/user_pages_spec.rb:150:in `block (4 levels) in ' 7) User pages edit with valid information Failure/Error: fill_in "Name", with: new_name 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/requests/user_pages_spec.rb:150:in `block (4 levels) in ' 8) User pages edit with valid information Failure/Error: fill_in "Name", with: new_name 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/requests/user_pages_spec.rb:150:in `block (4 levels) in ' 9) User pages edit with valid information Failure/Error: fill_in "Name", with: new_name 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/requests/user_pages_spec.rb:150:in `block (4 levels) in ' Finished in 5.78 seconds 112 examples, 9 failures Failed examples: rspec ./spec/requests/user_pages_spec.rb:119 # User pages signup with valid information should create a user rspec ./spec/requests/user_pages_spec.rb:116 # User pages signup with valid information after saving the user rspec ./spec/requests/user_pages_spec.rb:115 # User pages signup with valid information after saving the user rspec ./spec/requests/user_pages_spec.rb:114 # User pages signup with valid information after saving the user rspec ./spec/requests/user_pages_spec.rb:158 # User pages edit with valid information rspec ./spec/requests/user_pages_spec.rb:159 # User pages edit with valid information rspec ./spec/requests/user_pages_spec.rb:157 # User pages edit with valid information rspec ./spec/requests/user_pages_spec.rb:160 # User pages edit with valid information rspec ./spec/requests/user_pages_spec.rb:161 # User pages edit with valid information
这是我列表中的当前(错误)代码,因为练习已更改它们:
edit.html.erb
Update your profile
new.html.erb
Sign up
代码清单9.50 部分用于新建和编辑表单字段。
应用程序/视图/用户/ _fields.html.erb
代码清单9.51 具有partial的新用户视图。
/users/new.html.erb
Sign up
app/views
更新:已解决,恢复到运动前条件并将用户规格更改为“确认”而不是“密码确认”
describe "with valid information" do before do fill_in "Name", with: "Example User" fill_in "Email", with: "user@example.com" fill_in "Password", with: "foobar" fill_in "Confirmation", with: "foobar" end