У меня есть тест на create
:Тестирование действия обновления в MiniTest
test "should create article" do
assert_difference('Article.count') do
post :create, article: {title: "Test", body: "Test article."}
end
assert_redirected_to article_path(assigns(:article))
end
Я хочу сделать что-то подобное для update
действия.
Моя update
действие выглядит следующим образом:
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end
Я имею в виду что-то вроде:
test "should update article" do
patch :update, article {title: "Updated", body: "Updated article."}
end
Но я проблемы: как проверить, моя статья обновляется в MiniTest? И как найти элемент, который я собираюсь обновить? В светильниках есть две статьи.