Using FactoryBot, I'm having trouble creating a admin Factory in my specs because every user is assigned a default role of user in a before_create callback. This means that any role I assign a factory will be changed to user when the callback happens. 
What I really want to do is something like this:
Inside my spec
admin = FactoryBot.create(:user)
admin.role = 'admin'
The second line, admin.role = 'admin' doesn't do anything. Any ideas? 
I'm open to better ways of doing this as well.
There might be a way of reassigning the value to a FactoryBot (formerly FactoryGirl) instantiation, but RSpec negates the need:
describe User do
  let(:user) { FactoryBot.create(:user) }
  context 'when admin' do
    let(:user) { FactoryBot.create(:user, admin: true) }
    # ...
  end
end
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With