2
일부 통합 테스트를 수행하여 기사가 업데이트되었는지 확인하려고합니다. 여기Ruby와의 통합 테스트 및 할당 키워드
test "update existing article" do
# create an article
@article = Article.new
@article.title = "title"
@article.abstract = "abstract"
@article.description = "description"
if @article.save
post "/articles/edit", :id => @article.id
assert assigns(:article)
end
end
그리고 내 articles_controller 구현 한 것입니다 :
이def edit
@article = Article.find(params[:id])
respond_to do |format|
format.html
format.xml { render :xml => @article }
end
end
양수인에 대한 테스트의 마지막 줄에 실패 여기 내 통합 테스트입니다. 내 이해에서 assigns (: article) 변수 @article 채워집니다 의미합니다.
post "/articles/edit", :id => @article.id
문제는 편집 작업이 GET
아닌 POST
걸린다, 그래서 아마 호출되지 점점 적도 :
을 GET을 사용하여 편집 나는 다음과 같은 오류가 발생합니다 : 1) 오류 : test_update_existing_article (ArticleFlowsTest) : 하면 ArgumentError : 잘못된 인수 (예상 URI 객체 또는 URI 문자열)'test_update_existing_article ' – azamsharp
내가 통합 테스트를 실행하고 /test/integration/adding_article_flows_test.rb:30:in ! – azamsharp
아, 죄송합니다. 위의 내 업데이트를 사용하고': edit'에'edit_article_path'라는 이름을 붙여보십시오. –