2010-12-20 5 views
1

ここにある私のRSPECの束が今RSpecの2.3とRailsを3.0.3Rspec 2.3 on Rails 3.0.3ではコントローラのアクセスにいくつかの問題がありますか?

例を自分のアプリケーションを移動した後に失敗するテストを思わ:

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%を確認することはできません。

どのような考えですか?御時間ありがとうございます!

UPDATE:

get :new 

も動作し、私のUserSessionsコントローラ(Authlogic)は、この問題に苦しむしていないようです。私が言うことができるUserSessionsコントローラ、モデル、またはテストでは、私がやったことは何もありません。スペックで

答えて

2

でメソッドを呼び出してみてください。

delete :destroy, :id => "1" 
+0

うん、動作します。 Rails 3は、引数がなければ引数を必要とするHTMLメソッドのルートを認識しないように見えます。 – hahuang65

関連する問題