title: RSpec "count" change.by?
body: <p>So I was looking at: <a href="https://rubyplus.com/articles/1491-Basic-TDD-in-Rails-Writing-Validation-Tests-for-the-Model" rel="noreferrer">https://rubyplus.com/articles/1491-Basic-TDD-in-Rails-Writing-Validation-Tests-for-the-Model</a></p>
  
  <p>Just seeing techniques of testing and I saw this:</p>
  
  <pre><code>require 'rails_helper'
  
  describe Article, type: :model do
    it 'is valid if title and description fields have value' do
      expect do
        article = Article.new(title: 'test', description: 'test')
        article.save
      end.to change{Article.count}.by(1)
    end
  end
  </code></pre>
  
  <p>Specifically the last line: <code>end.to change{Article.count}.by(1)</code>. From reading <a href="https://relishapp.com/rspec/rspec-expectations/v/3-7/docs/built-in-matchers/change-matcher" rel="noreferrer">https://relishapp.com/rspec/rspec-expectations/v/3-7/docs/built-in-matchers/change-matcher</a></p>
  
  <p>It says specifically: </p>
  
  <blockquote>
    <p>The change matcher is used to specify that a block of code changes
    some mutable state. You can specify what will change using either of
    two forms:</p>
  </blockquote>
  
  <p>Which makes sense. But were testing <code>Article.count</code> in the block of code which isn't actually "doing" anything (The <code>article.save</code> is what actually changed the <code>Article.count</code> so how exactly does this work? Does the test take a a look at whats in the block of code before it's ran and "prerun" it...the compare the <code>.by(1)</code> after?</p>
  
  <p>Thanks</p>