我读完了 Michael Hartl 的 Ruby on Rails 教程的第 9 章,但 rspec 测试失败了。我已经多次浏览了这一章,但找不到我做错了什么。请帮忙!另外,我是一个两周大的程序员,所以如果您能详细说明您通过调试所经历的步骤,那将对我有很大帮助!
我的 git repo 位于https://github.com/kerrieyee/sample_app和 rspec 结果如下:
Macintosh-143:sample_app jeffreyyee$ bundle exec rspec spec/
..................................................................FF........FFFF.........
Failures:
1) User pages index delete links as an admin user
Failure/Error: it { should have_link('delete', href: user_path(User.first)) }
expected link "delete" to return something
# ./spec/requests/user_pages_spec.rb:45:in `block (5 levels) in <top (required)>'
2) User pages index delete links as an admin user should be able to delete another user
Failure/Error: expect { click_link('delete') }.to change(User, :count).by(-1)
Capybara::ElementNotFound:
no link with title, id or text 'delete' found
# (eval):2:in `click_link'
# ./spec/requests/user_pages_spec.rb:47:in `block (6 levels) in <top (required)>'
# ./spec/requests/user_pages_spec.rb:47:in `block (5 levels) in <top (required)>'
3) User pages signup with valid information should create a user
Failure/Error: fill_in "Confirmation", with: "foobar"
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'Confirmation' found
# (eval):2:in `fill_in'
# ./spec/requests/user_pages_spec.rb:96:in `block (4 levels) in <top (required)>'
4) User pages signup with valid information after saving the user
Failure/Error: fill_in "Confirmation", with: "foobar"
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'Confirmation' found
# (eval):2:in `fill_in'
# ./spec/requests/user_pages_spec.rb:96:in `block (4 levels) in <top (required)>'
5) User pages signup with valid information after saving the user
Failure/Error: fill_in "Confirmation", with: "foobar"
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'Confirmation' found
# (eval):2:in `fill_in'
# ./spec/requests/user_pages_spec.rb:96:in `block (4 levels) in <top (required)>'
6) User pages signup with valid information after saving the user
Failure/Error: fill_in "Confirmation", with: "foobar"
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'Confirmation' found
# (eval):2:in `fill_in'
# ./spec/requests/user_pages_spec.rb:96:in `block (4 levels) in <top (required)>'
Finished in 4.83 seconds
89 examples, 6 failures
Failed examples:
rspec ./spec/requests/user_pages_spec.rb:45 # User pages index delete links as an admin user
rspec ./spec/requests/user_pages_spec.rb:46 # User pages index delete links as an admin user should be able to delete another user
rspec ./spec/requests/user_pages_spec.rb:99 # User pages signup with valid information should create a user
rspec ./spec/requests/user_pages_spec.rb:108 # User pages signup with valid information after saving the user
rspec ./spec/requests/user_pages_spec.rb:109 # User pages signup with valid information after saving the user
rspec ./spec/requests/user_pages_spec.rb:110 # User pages signup with valid information after saving the user