我試圖掌握TDD的一些概念,並在我的RoR應用程序中關於屬於static_pages#about的視圖。它具有route.rb get 'about' => 'static_pages#about'
中定義的路由。一切工作到目前爲止瀏覽器,但我想也由RSpec測試它。 鑑於如何測試是否渲染了正確的模板(RSpec Rails)?
RSpec.describe "about.html.erb", type: :view do
it "renders about view" do
render :template => "about"
expect(response).to render_template('/about')
end
end
引發錯誤
Missing template /about with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :......
謝謝!
您是否嘗試刪除'/'? 'expect(response).to render_template(「about」)' – fabersky