describe "#subscription_cancelled_at" dolet!(:user) { FactoryBot.create(:user, stripe_id: 'stripe') }let!(:stripe_customer) { Stripe::Customer.new }let!(:past_date) { 2.weeks.ago }let!(:future_date) { 2.weeks.from_now }let!(:subscription) { build_deep_struct(status: 'active', cancel_at_period_end: false, canceled_at: nil, current_period_end: future_date) }it 'returns nil if there is no subscription' doallow(user).to receive(:stripe_customer).and_return(nil)expect(user).to receive(:stripe_customer)expect(stripe_customer).to_not receive(:subscriptions)expect(user.subscription_cancelled_at).to be_nilendit "returns canceled_at if it is populated" dosubscription.canceled_at = past_dateallow(user).to receive(:stripe_customer).and_return(stripe_customer)allow(stripe_customer).to receive(:subscriptions).and_return([subscription])expect(user).to receive(:stripe_customer)expect(stripe_customer).to receive(:subscriptions)expect(user.subscription_cancelled_at.utc).to eq past_dateendit "returns current_period_end if subscription will cancel at period end" dosubscription.cancel_at_period_end = trueallow(user).to receive(:stripe_customer).and_return(stripe_customer)allow(stripe_customer).to receive(:subscriptions).and_return([subscription])expect(user).to receive(:stripe_customer)expect(stripe_customer).to receive(:subscriptions)expect(user.subscription_cancelled_at).to eq future_dateendit 'returns false otherwise' doallow(user).to receive(:stripe_customer).and_return(stripe_customer)allow(stripe_customer).to receive(:subscriptions).and_return([subscription])expect(user).to receive(:stripe_customer)expect(stripe_customer).to receive(:subscriptions)expect(user.subscription_cancelled_at).to be_nilendend
1) User::StripeCustomer#subscription_cancelled_at returns canceled_at if it is populatedFailure/Error: expect(user.subscription_cancelled_at.utc).to eq @@past_date
expected: 2021-02-11 18:48:06.455547000 +0000got: 2021-02-11 18:48:06.455546855 +0000
(compared using ==)
Diff:@@ -1 +1 @@-Thu, 11 Feb 2021 18:48:06 UTC +00:00+2021-02-11 18:48:06 UTC
# ./spec/models/user/stripe_customer_spec.rb:312:in `block (3 levels) in <top (required)>'2) User::StripeCustomer#subscription_cancelled_at returns current_period_end if subscription will cancel at period endFailure/Error: expect(user.subscription_cancelled_at).to eq @@future_date
expected: 2021-03-11 18:48:06.455753000 +0000got: 2021-03-11 10:48:06.455752849 -0800
(compared using ==)
Diff:@@ -1 +1 @@-Thu, 11 Mar 2021 18:48:06 UTC +00:00+2021-03-11 10:48:06 -0800
# ./spec/models/user/stripe_customer_spec.rb:321:in `block (3 levels) in <top (required)>'
--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/E9584261-2BFC-49BB-AC53-21991545F39F%40pobox.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CAKRXwc2D%2B8kagXdvf_2_RS%2BrYnJg9Z1pCgaOR%2B-d_8xB37S4XQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CAAk5Ok-68sKasxG3O6jwG4FisKVC3Sfa9w_WRx5PYeQLxJjRgw%40mail.gmail.com.