百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

fake_stripe

> 编程语言
开源

一个 Stripe 假设,以便在测试中避免连接到 Stripe 服务器。

397 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个 Stripe 假设,以便在测试中避免连接到 Stripe 服务器。

Deprecated as of September 19, 2024

fake_stripe has been deprecated in favor of stripe-ruby-mock.

fake_stripe, a Stripe fake

This library is a way to test Stripe code without hitting Stripe's servers. It uses Capybara::Server and Webmock to intercept all of the calls from Stripe's Ruby library and returns JSON that the Stripe library can parse.

Installation

Gemfile

Add the fake_stripe Gem to the :test group in your Gemfile:

ruby
# Gemfile
group :test do
  gem 'fake_stripe'
end

Remember to run bundle install.

Stripe settings

Set the STRIPE_JS_HOST constant in an initializer:

ruby
# config/initializers/stripe.rb
Stripe.api_key = ENV['STRIPE_API_KEY']

unless defined? STRIPE_JS_HOST
  STRIPE_JS_HOST = 'https://js.stripe.com'
end

Include the Stripe JavaScript in your application template.

For Stripe.js v1:

rhtml
# app/views/layouts/application.html.erb

For Stripe.js v2:

rhtml
# app/views/layouts/application.html.erb

For Stripe.js v3:

rhtml
# app/views/layouts/application.html.erb

When the test suite runs fake_stripe will override the address for STRIPE_JS_HOST and serve up a local version of Stripe.js.

In Tests

Require the library in your spec support:

ruby
# spec/support/fake_stripe.rb
require 'fake_stripe'

RSpec.configure do |config|
  config.before(:each) do
    FakeStripe.stub_stripe
  end
end

Contributing

Please see CONTRIBUTING.md for more details.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言