RailsでRsecを使って非常に単純なものをテストしようとしています。Rspecを使ってRailsでテストする---> ActionView :: MissingTemplate:
これはこれは、コントローラ/ movies_controller.rbにおけるコントローラのメソッドであるスペック/コントローラ/ movies_controller_spec.rbのコードのテストピース
describe MoviesController do
describe 'update' do
it 'should call the model method to look up the movie to update' do
Movie.should_receive(:find).with("3")
put :update, {:id => "3"}
end
end
です:
def update
Movie.find(params[:id])
end
そして、私はこの問題を取得します:
1) MoviesController update should call the model method to look up the movie to update Failure/Error: post :update, {:id => "3"} ActionView::MissingTemplate: Missing template movies/update, application/update with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:html], :locale=>[:en, :en]}. Searched in: * "#<RSpec::Rails::ViewRendering::EmptyTemplatePathSetDecorator:0xa65b300>" # ./spec/controllers/movies_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
私のルートは次のようになります。
movies GET /movies(.:format) {:action=>"index", :controller=>"movies"}
POST /movies(.:format) {:action=>"create", :controller=>"movies"}
new_movie GET /movies/new(.:format) {:action=>"new", :controller=>"movies"}
edit_movie GET /movies/:id/edit(.:format) {:action=>"edit", :controller=>"movies"}
movie GET /movies/:id(.:format) {:action=>"show", :controller=>"movies"}
PUT /movies/:id(.:format) {:action=>"update", :controller=>"movies"}
DELETE /movies/:id(.:format) {:action=>"destroy", :controller=>"movies"}
誰でも私を助けて、私がこのような簡単な例で何が間違っているのか教えてください。
それは/映画を見てみてください – Bijan
を更新1で同様の問題を抱えていないので、更新の最後にredirect_toのmovie_pathに入れてみてくださいプロジェクトでは、最悪の部分は、単一のspecファイルでrspecを呼び出すときに表示されないことです! –