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
割り当てについてのテストの最後の行に障害が発生しました。私の理解から、assigns(:article)は、変数@articleが移入されることを意味します。
GETを使用して編集私は次のエラーを取得する:1)エラー: test_update_existing_article(ArticleFlowsTest): と、ArgumentError:悪い引数は(URIオブジェクトまたはURI文字列を期待) – azamsharp
「test_update_existing_article '/test/integration/adding_article_flows_test.rb:30:in私は統合テストを実行しています! – azamsharp
ああ、申し訳ありません!上記の私の更新を使ってみて、 ':edit'に' edit_article_path'を下書きしてみてください。 –