質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

2回答

629閲覧

Railsチュートリアル13章 13.2.3のテストでエラーを解消できません

akairen

総合スコア18

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2019/12/30 06:03

編集2019/12/31 13:40

Rails チュートリアル13章の13.2.3のテストを実行した結果以下のようなエラーが出てしまい解消できずにいます

発生している問題・エラーメッセージ

Running via Spring preloader in process 2324 Traceback (most recent call last): 54: from -e:1:in `<main>' 53: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require' 52: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require' 51: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:285:in `load' 50: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:257:in `load_dependency' 49: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:285:in `block in load' 48: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load' 47: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load' 46: from /Users/kuritahajime/sample_app/bin/rails:9:in `<top (required)>' 45: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:291:in `require' 44: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:257:in `load_dependency' 43: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:291:in `block in require' 42: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' 41: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi' 40: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' 39: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi' 38: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require' 37: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.4/lib/rails/commands.rb:18:in `<top (required)>' 36: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.4/lib/rails/command.rb:46:in `invoke' 35: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.4/lib/rails/command/base.rb:69:in `perform' 34: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-1.0.0/lib/thor.rb:399:in `dispatch' 33: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-1.0.0/lib/thor/invocation.rb:127:in `invoke_command' 32: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-1.0.0/lib/thor/command.rb:27:in `run' 31: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.4/lib/rails/commands/test/test_command.rb:33:in `perform' 30: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.4/lib/rails/test_unit/runner.rb:39:in `run' 29: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.4/lib/rails/test_unit/runner.rb:50:in `load_tests' 28: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.4/lib/rails/test_unit/runner.rb:50:in `each' 27: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.4/lib/rails/test_unit/runner.rb:50:in `block in load_tests' 26: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:291:in `require' 25: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:257:in `load_dependency' 24: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:291:in `block in require' 23: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' 22: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi' 21: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' 20: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi' 19: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require' 18: from /Users/kuritahajime/sample_app/test/helpers/sessions_helper_test.rb:3:in `<top (required)>' 17: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:291:in `require' 16: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:257:in `load_dependency' 15: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.4/lib/active_support/dependencies.rb:291:in `block in require' 14: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' 13: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi' 12: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' 11: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi' 10: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require' 9: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionview-5.2.4/lib/action_view/test_case.rb:10:in `<top (required)>' 8: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionview-5.2.4/lib/action_view/test_case.rb:12:in `<module:ActionView>' 7: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionview-5.2.4/lib/action_view/test_case.rb:13:in `<class:TestCase>' 6: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionpack-5.2.4/lib/action_controller/railties/helpers.rb:19:in `inherited' 5: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionpack-5.2.4/lib/abstract_controller/helpers.rb:108:in `helper' 4: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionpack-5.2.4/lib/action_controller/metal/helpers.rb:94:in `modules_for_helpers' 3: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionpack-5.2.4/lib/abstract_controller/helpers.rb:144:in `modules_for_helpers' 2: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionpack-5.2.4/lib/abstract_controller/helpers.rb:144:in `map!' 1: from /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionpack-5.2.4/lib/abstract_controller/helpers.rb:148:in `block in modules_for_helpers' /Users/kuritahajime/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionpack-5.2.4/lib/abstract_controller/helpers.rb:151:in `rescue in block in modules_for_helpers': Missing helper file helpers/microposts_helper.rb (AbstractController::Helpers::MissingHelperError)

試したこと

このエラーについて調べてみた結果Railsのバグのよで下の記事などにもある通りファイル名を変えると解消されるということのようなので以下の通りファイル名を変えてみたのですが解消できませんでした

$ mv microposts_helper.rb 1.rb $ mv 1.rb microposts_helper.rb

参考記事

https://qiita.com/kiyodori/items/f41408f3da626fbb0bbe
http://neos21.hatenablog.com/entry/2017/03/23/010854

これはそもそも別の部分に問題があるのでしょうか?
お分かりになる方がいらっしゃいましたらご教授願います

追記

microposts.yml

orange:
content: "I just ate an orange!"
created_at: <%= 10.minutes.ago %>
user: michael

tau_manifesto:
content: "Check out the @tauday site by @mhartl: http://tauday.com"
created_at: <%= 3.years.ago %>
user: michael

cat_video:
content: "Sad cats are sad: http://youtu.be/PKffm2uI4dk"
created_at: <%= 2.hours.ago %>
user: michael

most_recent:
content: "Writing a short test"
created_at: <%= Time.zone.now %>
user: michael

<% 30.times do |n| %>
micropost_<%= n %>:
content: <%= Faker::Lorem.sentence(5) %>
created_at: <%= 42.days.ago %>
user: michael
<% end %>

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

maisumakun

2019/12/30 06:09

microposts_helper.rbのパスと中身はどの様になっていますでしょうか?
akairen

2019/12/30 16:23

microposts_helper.rbの中身は空です
guest

回答2

0

fixtureファイルにタイプミスがあるかも知れません。特にeach文あたりを探すと良いと思います。

投稿2019/12/30 23:51

G.P.M

総合スコア13

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

akairen

2019/12/31 13:40 編集

fixtureファイルの中身(microposts.ymlとusers.yml)をRailsチュートリアルのコピペにしてテストをしてみたのですがエラーは解消されませんでした
guest

0

1行目にSpringのエラー文があるので、Springを再起動してみてはいかがでしょうか。

https://qiita.com/residenti/items/937d9fa3e98eaa498ff6

ここに詳しく書いてあります

投稿2019/12/30 07:41

G.P.M

総合スコア13

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

akairen

2019/12/30 16:23

springの再起動してみたのですが新しいエラーが出てきてしまいました UsersIndexTest#test_index_including_pagination: NameError: uninitialized constant ActiveRecord::FixtureSet::RenderContext::Faker test/fixtures/microposts.yml:23:in `block in get_binding' test/fixtures/microposts.yml:21:in `times' test/fixtures/microposts.yml:21:in `get_binding' Error: UsersIndexTest#test_index_including_pagination: NoMethodError: undefined method `each' for nil:NilClass このエラーについて調べてみたところ、ファイル名とクラス名が一致していない時に発生するエラーのようなのでファイル名を変更した時にタイプミスなどをしたのかと思い何度か繰り返し試したのでしたが解消されませんでした
G.P.M

2020/01/01 07:31

fixturesを読み込んでないか、タイプミスがないか、Faker gemのバージョンのエラーかくらいだと思うんですけど、、、 役に立たずすいません。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問