0

私のセッションコントローラー

def create
    auth = request.env["omniauth.auth"]
    person=Person.find_by_provider_and_uid(auth.provider,auth.uid) || Person.create_with_omniauth(auth)
    session[:user_id] = person.id
    redirect_to root_path
  end

  def failure
    redirect_to signin_path , alert: "Authentication failed, please try again." 
  end

sessions_controller_test.rb に失敗アクションをテストするためのテストを書きました

 it "failure should redirect to signin_path" do
     get :failure
     assert_redirected_to :action => 'new'   
     assert_response :redirect 
 end

しかし、simplecov コード カバレッジ ツールは、このテストを成功として受け入れません。Simplecov は、この失敗アクションをテストの欠落として示します。障害アクションのコントローラー テストを作成するにはどうすればよいですか。誰もこれについて何か考えを与えませんか? 下の画像は取材レポートのスクリーンショットです。

ここに画像の説明を入力

4

1 に答える 1

0

以下のようにassert_redirect_toステートメントでコントローラー名 (できればセッション) を指定してみてください。

assert_redirected_to :action => "new", :controller => "sessions"
于 2013-03-19T08:37:42.370 に答える