Failures:
1) User pages signup with valid information edit with invalid information
Failure/Error: before { click_button "Save changes" }
AbstractController::ActionNotFound:
The action 'update' could not be found for UsersController
# (eval):2:in `click_button'
# ./spec/requests/user_pages_spec.rb:105:in `block (6 levels) in <top (required)>'
Finished in 1.13 seconds
62 examples, 1 failure
Failed examples:
rspec ./spec/requests/user_pages_spec.rb:107 # User pages signup with valid information edit with invalid information
我爲此感到它沒有看到我的users_controller.rb我的更新動作但是它的存在:失敗的測試9
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
sign_in @user
flash[:success] = "Welcome to the Sample App!"
redirect_to @user
else
render 'new'
end
end
def edit
@user = User.find(params[:id])
end
end
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:success] = "Profile updated"
sign_in @user
redirect_to @user
else
render 'edit'
end
end
我莫名其妙地結束了兩個編輯行動,但如果我刪除其中的一個,我可以讓測試運行。我認爲我遇到的麻煩中有99%是隨處可見的,並在錯誤的地方插入新的行爲。感謝您的幫助
三江源是非常有意義!我剛剛刪除了重複編輯操作的雙端,並添加了一個結尾,它通過了!但是,我可以請你看看我的user_pages_spec嗎?我也遇到了失敗的測試,我希望它的內容也很簡單。 http://pastebin.com/a7tScj4s再次感謝! – jfoutch
這是一個失敗:1)用戶頁面註冊有效信息 失敗/錯誤:fill_in「密碼」,與:user.password NameError: 未定義的局部變量或方法'用戶'爲# #./spec/requests/user_pages_spec.rb:119:in ' –
jfoutch
我沒有太多經驗與測試。爲此提出一個新問題可能是一個好主意。從你添加的粘貼的外觀和錯誤:你沒有在你的測試中定義'user'。這應該是一個變量,我最好的猜測是它應該出自FactoryGirl類。 –