I have a Subscription model that makes a 3rd party API call to Stripe in an after_save.
I've read posts and heard opinions that making 3rd party API calls in a model is a bad idea/design flaw, and it should be moved to an observer. However, this is a business critical component of the model so I think it is smart to keep it attached to the model. If the call to Stripe fails or throws an error, I want to rollback the transaction immediately and show the user the error to fix, which is most likely incorrectly entered credit card info.
So every time my factory creates a Subscription, it makes an API call. My question is: Is there any way I can use VCR to define a cassette IN the factory? So every time I call FactoryGirl.create(:subscription), VCR knows to use a cassette for those resulting API calls to Stripe.
If it's not possible, do you have any tips on how I should better design the logic of the app?