我想测试的东西非常简单,RSEC在我的Rails应用程序。Rails的使用Rspec的测试---> ::的ActionView MissingTemplate:
这是符合规格的试验片的代码/控制器/ 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
这是在控制器/ movies_controller.rb控制器方法:
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"}
任何人都可以请帮助我,告诉我在这样一个简单的例子中我做错了什么?
尝试在更新结束投入redirect_to的movie_path所以它不会尝试去寻找电影/更新 – Bijan 2012-03-22 20:48:33
在一个有一个类似的问题项目,最糟糕的部分是它在单个spec文件上调用rspec时不显示! – 2012-04-21 19:20:54