0

Hello I am testing the stripe subscription and I am having a trouble when I called a method because appear this error when I try to run the test:

Failure/Error:
   data_stripe = Stripe::Subscription.create({
     customer: user.stripe_id,
     items: [
       { price: ENV['SUBSCRIPTION_PRODUCT_PREMIUM'] }
     ]
   })
 ArgumentError:
   unknown keyword: :write_timeout

Can you help me?

This is my SubscriptionService:

 class SubscriptionsService
  def save_subscription_to_stripe(user)
    data_stripe = Stripe::Subscription.create({
                                              customer: user.stripe_id,
                                              items:[{price:ENV['SUBSCRIPTION_PRODUCT_PREMIUM'] }]})
    save_subscription(data_stripe, user)
  end
end

And this is my Spec Test:

require 'rails_helper'
RSpec.describe "subscriptions_service.rb", type: :controller do
  let(:current_user) { create(:user, :confirmed_user) }
  let(:subscription) { Stripe::SubscriptionsService.new }
  let(:card_params) do
  {
    number: "4242424242424242",
    exp_month: "08",
    exp_year: "2023",
    cvc: "123"
  }
end
let(:card) { Stripe::CardsService.new(current_user, card_params) }

before do
  sign_in(current_user)
  VCR.insert_cassette("VCR Stripe create card")
  card.create_card
end

it "Validate user has a credit card" do
  expect(current_user.reload.card).to be_valid
end

describe "Subscription stripe" do
  it "Succesfully added" do
    VCR.eject_cassette
    VCR.insert_cassette("VCR Stripe create subscription", record: :new_episodes)
    subscription.save_subscription_to_stripe(current_user)
    expect(current_user.reload.subscription).to be_valid
  end
end

teardown do
  VCR.eject_cassette
end

end

AldoAx2
  • 1
  • 1
  • Please provide the full stacktrace of the error. It's impossible to give an answer to this without more information. – Christian Bruckmayer Oct 16 '21 at 01:03
  • Does this answer your question? [Selenium Webdriver ruby upgrade (write\_timeout error)](https://stackoverflow.com/questions/54816782/selenium-webdriver-ruby-upgrade-write-timeout-error) – karbi Oct 16 '21 at 01:12
  • I have added the entire error – AldoAx2 Oct 16 '21 at 01:21
  • I have the latest gem versions of WebMock and VCR – AldoAx2 Oct 16 '21 at 01:28
  • I have find the bug, it was the web mock versión wasn't compatible, then I have change to the latest and specify the gem WebMock version and its working, Thank you – AldoAx2 Oct 16 '21 at 02:11

0 Answers0