2011-09-16 11 views
-1

"before_filter:authenticate、:only:> [:edit]"を使用しないと、このエラーが発生します。 失敗/エラー:response.should redirect_to(signin_path ) i "はbefore_filter:認証を、:のみ=> [編集]" を追加した場合、あなたがしている場合は、IAM失敗/エラー:response.should redirect_to(signin_path)

1) UsersController GET 'edit' should be successfull 
    Failure/Error: response.should be_success 
     expected success? to return true, got false 
    # ./spec/controllers/users_controller_spec.rb:102:in `block (3 levels) in <top (required)>' 

    2) UsersController GET 'edit' should have the right title 
    Failure/Error: response.should have_selector('title', :content => "Edit user") 
     expected following output to contain a <title>Edit user</title> tag: 
     <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> 
     <html><body>You are being <a href="http://test.host/signin">redirected</a>.</body></html> 
    # ./spec/controllers/users_controller_spec.rb:106:in `block (3 levels) in <top (required)>' 

    3) UsersController GET 'edit' should have a link to change the Gravatar 
    Failure/Error: response.should have_selector('a', :href => 'http://gravatar.com/emails', 
     expected following output to contain a <a href='http://gravatar.com/emails'>change</a> tag: 

のようないくつかの他のエラーを取得しては私に可能な解決策....

答えて

0

を提案してくださいコントローラー仕様のセレクターをテストするには、render_views

describe UsersController do 
    render_views 
    ... 
end 
+0

.....私のために働いたの前にありがとう、多くの先生....私のコードをもう一度チェックするように私からの提案は... – shridhar

0

ええ、私はそれを得た...編集がこの

def edit 
    @user = User.find([:id]) 
    @title = "Edit user" 
end 

のように定義されており、最終的に私は

def edit 
    @user = User.find(params[:id]) 
    @title = "Edit user" 
end 

としてそれを作ったので、それは

関連する問題