RSpec、Capybara 和 Stripe 在必填产品字段上失败
RSpec, Capybara and Stripe failing on required product field
我正在尝试模拟与 Stripe 一起使用的 API 进程。在应用程序中,正在使用一个按钮来调用 Charge API。我在任何在线资源中都没有看到这一点,它们都指向使用计划 API。以下运行正常,只是它正在寻找必需的 product 字段。其他教程,例如 Mocking Stripe with Rspec don't include the product parameter at all. I've also attempted to mock it using the value in Stripe's API Reference 和其他硬编码值,但显示 产品不存在 。我已经尝试在 plan =
语句
中的一个或两个中使用它
context "stripe processor" do
let(:stripe_helper) { StripeMock.create_test_helper }
it "creates a stripe plan" do
plan = stripe_helper.create_plan(:id => 'my_plan', :amount => 1500)
# The above line replaces the following:
plan = Stripe::Plan.create(
:id => 'my_plan',
:name => 'StripeMock Default Plan ID',
:amount => 1500,
:currency => 'usd',
:interval => 'month'
)
expect(plan.id).to eq('my_plan')
expect(plan.amount).to eq(1500)
end
end
请注意,我使用的是 stripe-ruby-mock gem。感谢任何可能有想法的人。谢谢。
在较新的 API 版本中,product
参数指的是产品 ID,该产品必须在创建计划之前存在。参见 this api revision。对于测试,您需要确保在创建计划之前存在给定的产品 ID,否则您将收到您看到的错误消息。
您可以使用 stripe-ruby-mock
模拟产品和计划,但看起来 gem 是在那些 API 更改之前构建的,它可能需要修改才能工作此处正确。
我正在尝试模拟与 Stripe 一起使用的 API 进程。在应用程序中,正在使用一个按钮来调用 Charge API。我在任何在线资源中都没有看到这一点,它们都指向使用计划 API。以下运行正常,只是它正在寻找必需的 product 字段。其他教程,例如 Mocking Stripe with Rspec don't include the product parameter at all. I've also attempted to mock it using the value in Stripe's API Reference 和其他硬编码值,但显示 产品不存在 。我已经尝试在 plan =
语句
context "stripe processor" do
let(:stripe_helper) { StripeMock.create_test_helper }
it "creates a stripe plan" do
plan = stripe_helper.create_plan(:id => 'my_plan', :amount => 1500)
# The above line replaces the following:
plan = Stripe::Plan.create(
:id => 'my_plan',
:name => 'StripeMock Default Plan ID',
:amount => 1500,
:currency => 'usd',
:interval => 'month'
)
expect(plan.id).to eq('my_plan')
expect(plan.amount).to eq(1500)
end
end
请注意,我使用的是 stripe-ruby-mock gem。感谢任何可能有想法的人。谢谢。
在较新的 API 版本中,product
参数指的是产品 ID,该产品必须在创建计划之前存在。参见 this api revision。对于测试,您需要确保在创建计划之前存在给定的产品 ID,否则您将收到您看到的错误消息。
您可以使用 stripe-ruby-mock
模拟产品和计划,但看起来 gem 是在那些 API 更改之前构建的,它可能需要修改才能工作此处正确。