2

rspecテストフレームワークを使用して、rails4に基づくマウント可能なエンジンに取り組んでいます。「rg scaffold post title content」を介してシンプルなアプリを作成しました。ビューのテストを除いて、すべてが正常に機能しました。rake app:spec:views を実行すると、常に次のように表示されます。

" 失敗/エラー: レンダリング ActionView::MissingTemplate: Missing template posts/indexwith {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, : png、:jpeg、:gif、:bmp、:tiff、:mpeg、:xml、:rss、:at​​om、:yaml、:multipart_form、:url_encoded_form、:json、:pdf、:zip]、:handlers=>[ :erb, :builder, :raw, :ruby]}. 検索場所: * "/projects/_plugins/blorgh4m_rspect/spec/dummy/app/views" * "/projects/_plugins/blorgh4m_rspect/app/views"

「render」を「render template: "blorgh4m_rspect/posts/show"」に変更すると、エラーになりました

"失敗/エラー: レンダリング テンプレート: "blorgh4m_rspect/posts/index" ActionView::Template::Error: undefined method post_path' for #<#<Class:0x0000000427cb40>:0x00000004ff97f0> # ./app/views/blorgh4m_rspect/posts/index.html.erb:21:inblock in home_elbbub _works_projects__plugins_blorgh_m_rspect_app_views_blorgh_m_rspect_posts_index_html_erb__56995883415291959_42058840' each' # ./app/views/blorgh4m_rspect/posts/index.html.erb:15:inhome_elbbub _works_projects__plugins_blorgh_m_rspect_app_views_blorgh_m_rspect_posts_index_html_erb__569958834415291959_42058840' # ./spec/views/blorgh4m_rspect/posts/index.html.erb_spec.rb:20:in `ブロック (2 レベル) in ' "

すべてのルート パス ヘルパーが無効のようです。

この種のケースに遭遇した人はいますか?そして、あなたはそれについて何か考えがありますか?

4

1 に答える 1

3

ルートに名前を付ける必要があります。http://guides.rubyonrails.org/engines.html#routes

engine_name.post_path
于 2013-09-10T16:39:54.280 に答える