From beb916d24d7a285aea147e0412d2a41d8f686676 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 19 Dec 2023 16:17:56 +0000 Subject: [PATCH] Improves assertions around disconnect-failure and -success test cases --- spec/models/stripe_account_spec.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/spec/models/stripe_account_spec.rb b/spec/models/stripe_account_spec.rb index 4aae9c5a9e..374f7ee640 100644 --- a/spec/models/stripe_account_spec.rb +++ b/spec/models/stripe_account_spec.rb @@ -24,9 +24,13 @@ describe StripeAccount do before { Stripe.client_id = "bogus_client_id" } it "destroys the record and notifies Bugsnag" do + # returns status 401 expect(Bugsnag).to receive(:notify) - stripe_account.deauthorize_and_destroy - expect(StripeAccount.all).to_not include(stripe_account) + expect { + stripe_account.deauthorize_and_destroy + }.to change( + StripeAccount.where(stripe_user_id:), :count + ).from(1).to(0) end end @@ -34,8 +38,14 @@ describe StripeAccount do before { Stripe.client_id = client_id } it "destroys the record" do + # returns status 200 + expect(Bugsnag).to_not receive(:notify) stripe_account.deauthorize_and_destroy - expect(StripeAccount.all).not_to include(stripe_account) + expect { + stripe_account.deauthorize_and_destroy + }.to change( + StripeAccount.where(stripe_user_id:), :count + ).from(1).to(0) end end