将我的应用程序移动到 Rspec 2.3 和 Rails 3.0.3 后,我的一堆 Rspec 测试现在似乎失败了
这里有一个例子:
it "should not be able to access 'destroy'" do
delete :destroy
response.should redirect_to(signin_path)
flash[:error].should == "You must be signed in to view this page."
end
会给我错误:
1) FriendshipsController when not logged in: should not be able to access 'destroy'
Failure/Error: delete :destroy
No route matches {:controller=>"friendships", :action=>"destroy"}
# ./spec/controllers/friendships_controller_spec.rb:21:in `block (3 levels) in <top (required)>'
在我的 routes.rb 文件中,我已经映射了这个控制器的资源......
resources :friendships
相同的
get :edit
get :show
put :update
只有一个似乎有效的是
post :create
但这我不能100%确认。
有什么想法吗?谢谢你的时间!
更新:
get :new
也可以工作,我的 UserSessions 控制器(Authlogic)似乎没有遇到这个问题。在我的 UserSessions 控制器、模型或测试中,我所做的一切都没有什么不同。