I am trying to check something very simple with Rsec in my Rails application.
This is a test piece of code in spec / controllers / 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
This is the controller method in the / movies _controller.rb controllers:
def update Movie.find(params[:id]) end
And I get this problem:
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>"
My routes look like this:
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"}
Can someone help me and tell me what the hell am I doing wrong with such a simple example?
source share