Tuesday, 10 September 2013

Testing view on Rails 4 mountable engine with Rspec

Testing view on Rails 4 mountable engine with Rspec

i'm working on a mountable engine based on rails4 with rspec testing
framework. I built a simply app through 'r g scaffold post title content'.
Everything worked fine except view testing. When i executed rake
app:spec:views, it always say:
" Failure/Error: render ActionView::MissingTemplate: Missing template
posts/indexwith {: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]}. Searched in: *
"/projects/_plugins/blorgh4m_rspect/spec/dummy/app/views" *
"/projects/_plugins/blorgh4m_rspect/app/views" "
so i change "render" to "render template: "blorgh4m_rspect/posts/show",
the error became
" Failure/Error: render template: "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__569958834415291959_42058840'
# ./app/views/blorgh4m_rspect/posts/index.html.erb:15:in 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 `block
(2 levels) in ' "
it looks like all the routes path helpers are invalid.
Has anybody met this kind of case? and do you have any idea about it?

No comments:

Post a Comment