0

Sorcery を使用する (または使用しようとする) アプリがあり、その仕様を書いています。

context "successfull attempts to log in" do
  let(:attr) { attributes_for(:credentials) }

  before(:each) do
    @user = create(:user, attr)
  end

  it "should log the user in" do
    post :create, attr.merge(remember_me: false)
    controller.should be_logged_in
  end
end

FactoryGirl ファクトリーは次のとおりです。

FactoryGirl.define do
  factory :user do
    email                 Faker::Internet.safe_email
    password              "password"
    password_confirmation { |u| u.password }
    client_id             1
  end

  factory :credentials, class: User do
    email       "user@example.com"
    password    "password"
  end
end

コントローラのアクションは次のとおりです。

class SessionsController < ApplicationController
  # ...
  def create
    login(params[:email], params[:email], params[:remember_me])
    flash.now[:error] = "Invalid email/password combination"
    render :new
  end
end

エラーメッセージは次のとおりです。

1) SessionsController POST 'create' successfull attempts to log in should log the user in
     Failure/Error: controller.should be_logged_in
       expected logged_in? to return true, got false
     # ./spec/controllers/sessions_controller_spec.rb:54:in `block (4 levels) in <top (required)>'

仕様は何らかの理由で失敗し続けます。誰か私に理由を説明してもらえますか?

4

1 に答える 1

1

コントローラーは、メールをユーザー名とパスワードの両方として使用します。これは、コピー アンド ペースト エラーのように見えます。あれは正しいですか?

于 2012-10-18T16:13:52.370 に答える