簡體   English   中英

使用Rspec在Rails 4可安裝引擎上的測試視圖

[英]Testing view on Rails 4 mountable engine with Rspec

我正在使用帶有rspec測試框架的基於rails4的可安裝引擎。 我通過“ rg scaffold post title content”構建了一個簡單的應用程序。 除視圖測試外,其他所有功能均正常運行。 當我執行rake app:spec:views時,它總是說:

“失敗/錯誤:渲染ActionView :: MissingTemplate:缺少模板帖子/索引,{:locale => [:en] 、: formats => [:html,:text,:js,:css,:ics,:csv 、: png,:jpeg,:gif,:bmp,:tiff,:mpeg,:xml,:rss,:atom,: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”“

所以我將“渲染”更改為“渲染模板:“ blorgh4m_rspect / posts / show”,錯誤變為

“錯誤/錯誤:呈現模板:” blorgh4m_rspect / posts / index“ ActionView :: Template :: Error:未定義的方法post_path' for #<#<Class:0x0000000427cb40>:0x00000004ff97f0> # ./app/views/blorgh4m_rspect/posts/index.html.erb:21:in /app/views/blorgh4m_rspect/posts/ post_path' for #<#<Class:0x0000000427cb40>:0x00000004ff97f0> # ./app/views/blorgh4m_rspect/posts/index.html.erb:21:in home_elbbub _works_projects__plugins_blorgh_m_rspect_app_views_blorgh_m_rspect_posts_index_html_erb__569958834415291959_42058840'#./app/ each' # ./app/views/blorgh4m_rspect/posts/index.html.erb:15:in home_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中(20)

看來所有路由路徑助手都無效。

有人遇到過這種情況嗎? 您對此有任何想法嗎?

您必須為路由命名空間。 http://guides.rubyonrails.org/engines.html#routes

engine_name.post_path

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM