2
我正在嘗試執行一些集成測試以查看文章是否得到更新。這裏是我的集成測試:與Ruby集成測試和assigns關鍵字
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
在測試的最後一行約受讓人失敗。從我理解的分配(:文章)意味着變量@article將被填充。
使用GET:編輯我收到以下錯誤:1)錯誤: test_update_existing_article(ArticleFlowsTest): ArgumentError:錯誤的參數(期望的URI對象或URI字符串) /test/integration/adding_article_flows_test.rb:30:in`test_update_existing_article' – azamsharp 2010-12-07 16:33:19