📜  rspec 期望计数增加 1 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:06.252000             🧑  作者: Mango

代码示例1
require 'rails_helper'

describe Article, type: :model do
  let(:create_article) { Article.create(title: 'test', description: 'test') }

  it 'is valid if title and description fields have value' do
    expect { create_article }.to change { Article.count }.by(1)
  end
end