title: Rails Rspec/Factory Bot isn't invoking model before_save callbacks
body: <p>I have a user model with a number of before_save callbacks - for example, one that strips leading and trailing whitespace:</p>
  
  <p>app/models/user.rb:</p>
  
  <pre><code>def strip_whitespace_in_user_names
    self.first_name.strip!
    self.first_name.gsub!(" ", "")
    self.last_name.strip!
    self.last_name.gsub!(" ", "")
  end
  </code></pre>
  
  <p>I have a basic model spec, and I'd like to check that this actually works. For example, " Nathan   " should return "Nathan"</p>
  
  <p>spec/models/user_spec.rb:</p>
  
  <pre><code>RSpec.describe User, type: :model do
    let(:user) { build :poorly_defined_user }
    it "has no leading white space" do
      expect(user.first_name).not_to end_with(" ")
    end
  end
  </code></pre>
  
  <p>Here is the factory definition of a poorly_defined_user:</p>
  
  <pre><code>require 'faker'
  password = Faker::Internet.password
  # Factory to define a user
  FactoryBot.define do
    factory :poorly_defined_user, class: User do
      first_name "     asd  "
      last_name "AS DF  "
      handle "BLASDF824"
      email Faker::Internet.email
      password password
      password_confirmation password
    end
  end
  </code></pre>
  
  <p>However, when I run the tests, this expectation fails. I checked on postman (this is for an API), and the callbacks are correctly run, and the user's attributes are properly set.</p>
  
  <p>Any help as to why this is happening, or, how to restructure my tests to reflect how Rspec/Factory Bot actually work.</p>