diff --git a/spec/enterprise/services/enterprise/billing/topup_checkout_service_spec.rb b/spec/enterprise/services/enterprise/billing/topup_checkout_service_spec.rb index 8a64e6fd2..24c7889de 100644 --- a/spec/enterprise/services/enterprise/billing/topup_checkout_service_spec.rb +++ b/spec/enterprise/services/enterprise/billing/topup_checkout_service_spec.rb @@ -44,17 +44,19 @@ describe Enterprise::Billing::TopupCheckoutService do end it 'raises error for invalid credits' do - expect do - service.create_checkout_session(credits: 500) - end.to raise_error(Enterprise::Billing::TopupCheckoutService::Error) + expect { service.create_checkout_session(credits: 500) }.to raise_error do |error| + expect(error.class.name).to eq('Enterprise::Billing::TopupCheckoutService::Error') + expect(error.message).to eq(I18n.t('errors.topup.invalid_option')) + end end it 'raises error when account is on free plan' do account.update!(custom_attributes: { plan_name: 'Hacker', stripe_customer_id: stripe_customer_id }) - expect do - service.create_checkout_session(credits: 1000) - end.to raise_error(Enterprise::Billing::TopupCheckoutService::Error) + expect { service.create_checkout_session(credits: 1000) }.to raise_error do |error| + expect(error.class.name).to eq('Enterprise::Billing::TopupCheckoutService::Error') + expect(error.message).to eq(I18n.t('errors.topup.plan_not_eligible')) + end end end end