내 테스트에 어떤 문제가 있는지 이해하는 데 어려움을 겪고 있지만 컨트롤러에 대한 업데이트 방법을 테스트 할 때 라우팅 일치가 계속 발생합니다. 브라우저를 통해 양식을 제출하면 작동합니다.레일 4 컨트롤러 테스트
내 경로 파일 :
namespace :merchant do
resources :users
get '/signup', to: "users#new"
end
내 컨트롤러 :
def update
respond_to do |format|
if @merchant_user.update(user_params)
format.html { redirect_to @merchant_user, notice: 'User was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'show' }
format.json { render json: @merchant_user.errors, status: :unprocessable_entity }
end
end
end
내 시험 :
test "should update user" do
user = users(:jon)
user.first_name="Jonas"
put :update, :merchant_user =>user.attributes
assert_response :success
끝
결과 :
1) Error:
Merchant::UsersControllerTest#test_should_update_user:
ActionController::UrlGenerationError: No route matches {:merchant_user=> {"id"=>"846114006", "email"=>"[email protected]", "first_name"=>"Jonas", "last_name"=>"Sims", "password_digest"=>"$2a$10$LVbV7pkd7li8sobYEauoS.4JVA2ZHzAXgPFbyiojYqgcDBHUE9bXW", "type"=>"Merchant::User", "created_at"=>"2013-07-11 22:59:41 UTC", "updated_at"=>"2013-07-11 22:59:41 UTC"}, :controller=>"merchant/users", :action=>"update"}
test/controllers/merchant/users_controller_test.rb:45:in `block in <class:UsersControllerTest>'
힌트가 있습니까?
나중에 테스트 하겠지만, 초보자가 Rails에서 다시 픽업 할 때 문제가되는 것 같습니다 :). –
그건 그랬어. Mohamad와 Leo Correa에게 감사드립니다. 나에게 도움이되었지만 레오의 대답을 받아 들일 것입니다. –