After, pulling my hair for a few hours, this is how I am testing it:
ruby
it 'does not creates a new subscription if stripe fails to create a token'do
exception = Stripe::InvalidRequestError.new("",{})
Stripe::Customer.should_receive(:create).and_raise(exception)
expect {
post :create, subscription: valid_attributes
}.to change(Subscription, :count).by(0)
end
The tricky part was creating the exception, I had to take a look at this
After, pulling my hair for a few hours, this is how I am testing it:
The tricky part was creating the exception, I had to take a look at this