私は Hartl の rails チュートリアル、セクション 9.2.1 の終わりに取り組んでいました。テストに合格しません。理由がわかりません。誰かが助けてくれることを願っています。エラー メッセージと 2 つの関連ファイル 1) authentication_pages_spec.rb と 2) users_controller.rb を以下に添付しました。
失敗:
1) 編集ページにアクセスする Users コントローラーでの、サインインしていないユーザーの認証承認 失敗/エラー: { should have_title('Sign in') } # ./spec/requests/authentication_pages_spec.rb:57:in `ブロック (6 レベル) in '
2) 更新アクションに送信するユーザー コントローラーでの、サインインしていないユーザーの認証許可 失敗/エラー: { パッチ user_path(user) } の前に ActionController::ParameterMissing: param not found: user # ./app/controllers/users_controller .rb:40:in user_params'
     # ./app/controllers/users_controller.rb:27:inupdate' # ./spec/requests/authentication_pages_spec.rb:61:in `ブロック (6 レベル) in '
2.08秒で完走 60例、2回失敗
失敗した例:
rspec ./spec/requests/authentication_pages_spec.rb:57 # 編集ページにアクセスする Users コントローラーの非サインイン ユーザーに対する認証承認 rspec ./spec/requests/authentication_pages_spec.rb:62 # 非署名ユーザーに対する認証承認-更新アクションにサブミットする Users コントローラーのユーザー
私の authentication_pages_spec.rb は
require 'spec_helper'
describe "Authentication" do
subject { page }
describe "signin page" do
    before { visit signin_path }
    it { should have_content('Sign in') }
    it { should have_title('Sign in') }
  end
describe "signin" do
      before { visit signin_path }
      describe "with invalid information" do
            before { click_button "Sign in" }
            it { should have_title('Sign in') }
            it { should have_selector('div.alert.alert-error', text: 'Invalid') }
            describe "after visiting another page" do
              before { click_link "Home" }
              it { should_not have_selector('div.alert.alert-error') }
            end
          end
    describe "with valid information" do
      let(:user) { FactoryGirl.create(:user) }
      before { sign_in user }
      it { should have_title(user.name) }
      it { should have_link('Profile',     href: user_path(user)) }
      it { should have_link('Settings',    href: edit_user_path(user)) }
      it { should have_link('Sign out',    href: signout_path) }
      it { should_not have_link('Sign in', href: signin_path) }
     describe "followed by signout" do
       before { click_link "Sign out" }
         it { should have_link('Sign in') }
       end
     end
  end
  describe "authorization" do
    describe "for non-signed-in users" do
      let(:user) { FactoryGirl.create(:user) }
      describe "in the Users controller" do
        describe "visiting the edit page" do
          before { visit edit_user_path(user) }
          it { should have_title('Sign in') }
        end
        describe "submitting to the update action" do
          before { patch user_path(user) }
          specify { expect(response).to redirect_to(signin_path) }
        end
      end
    end
  end        
end
users_controller.rb は
 class UsersController < ApplicationController
 def show
@user = User.find(params[:id])
 end
 def new
@user = User.new
 end
 def create
  @user = User.new(user_params)
  if @user.save
    flash[:success] = "Welcome to the Sample App!"
    redirect_to @user
  else
    render 'new'
  end
end
def edit
    @user = User.find(params[:id])
  end
def update
  @user = User.find(params[:id])
  if @user.update_attributes(user_params)
    flash[:success] = "Profile updated"
    sign_in @user
    redirect_to @user      
  else
    render 'edit'
  end
end
private
  def user_params
    params.require(:user).permit(:name, :email, :password,
                                 :password_confirmation)
  end
  # Before filters
  def signed_in_user
    redirect_to signin_url, notice: "Please sign in." unless signed_in?
  end       
end