2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruby on Rails チュートリアル 第4版 第10章 10.1.3 編集失敗時のテスト リスト 10.10がredになるエラー

Posted at

Ruby on Rails チュートリアル 第4版 第10章

10.1.3 編集失敗時のテスト

リスト 10.9: 編集の失敗に対するテストgreen

リスト 10.10: green
$ rails test

上記を実行したところgreenにならず、以下のようなエラー(red)になった。

(ターミナル)

$ rails test
Running via Spring preloader in process 5810
Started with run options --seed 10877

FAIL["test_invalid_signup_information", UsersSignupTest, 0.48510723200024586]
test_invalid_signup_information#UsersSignupTest (0.49s)
Expected at least 1 element matching "form[action="/signup"]", found 0..
Expected 0 to be >= 1.
test/integration/users_signup_test.rb:16:in `block in class:UsersSignupTest'

29/29: [=========================] 100% Time: 00:00:00, Time: 00:00:00

Finished in 0.67359s
29 tests, 74 assertions, 1 failures, 0 errors, 0 skips

#解決法

/sample_app/app/views/users/_form.html.erb

<%= form_for(@user) do |f| %>

<%= form_for(@user, url: yield(:form_path)) do |f| %>

に変更

/sample_app/app/views/users/new.html.erb

<% provide(:form_path, signup_path) %>

を追加

/sample_app/app/views/users/edit.html.erb

<% provide(:form_path, user_path) %>

を追加

再度$ rails testを行ったところ、結果がgreenになった。

(参考サイト)
https://stackoverflow.com/questions/41130656/running-into-error-in-the-micheal-hartl-ruby-on-rails-tutorial-section-10-1-1?rq=1

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?