0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【RSpec】リクエストテストupdateで値が更新されないとき

Last updated at Posted at 2021-11-09

##環境
Ruby 3.0.2
Rails 6.1.4.1

reloadでDBの値を更新するとテストが通る。

spec.rb
context '記事を編集する際、正しい値の場合' do
  let!(:post) { create(:post) }
  let!(:post_params) { attributes_for(:post, title: 'other') }
  it '記事を編集できること' do
    expect { subject }.not_to change(Post, :count)
    expect(response).to have_http_status(302)
    expect(post.reload.title).to eq 'other'
  end
end
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?