0.0
No commit activity in last 3 years
No release in over 3 years
Mimic Stripe calls without hitting Stripe's servers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 2.0.2
~> 1.4.3
~> 4.6.0
~> 10.0
~> 3.1.0
~> 1.23.0
~> 2.9.3

Runtime

~> 1.8.3
~> 1.4.6
~> 1.24.0
 Project Readme

StripeMock - WIP

This gem is Incomplete!

Only Transfers is fully stubbed out.

Setup for Stripe API version 2015-07-07

Installation

Add this line to your application's Gemfile:

gem 'stripe_mock', require: false

And then execute:

$ bundle

Or install it yourself as:

$ gem install stripe_mock

How does StripeMock work?

StripeMock uses Webmock to hijack the request to the Stripe servers and return the corresponding Stripe response.

Setup

To capture requests to Strip simply add these lines to your spec file

before(:all) do
  StripeMock.capture_requests
end

Mocked Requests

To get a mocked response, just use the Stripe gem as you normally would.

Stipe::Transfer.all

# #<Stripe::ListObject:0x3fe634d74498> JSON: {
#   "object": "list",
#   "url": "/v1/transfers",
#   "has_more": false,
#   "data": [
#     #<Stripe::Transfer id=tr_16DA2VCKrsNpguPAW93AVKPk 0x00000a> JSON: {
#       "id": "tr_16DA2VCKrsNpguPAW93AVKPk",
#       "object": "transfer",
#       "created": 1434184255,
#       "date": 1434240000,
#       ...
#     },
#     #<Stripe::Transfer[...] ...>,
#     #<Stripe::Transfer[...] ...>
#   ]
# }
Getting Transfer Failure Codes

To get the transfer failure_code filled in, just use the desired failure_code as the id of the transfer. EX:

Stripe::Transfer.retrieve('insufficient_funds')

All codes are listed here: https://stripe.com/docs/api/ruby#transfer_failures

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/digitalopera/stripe_mock.

License

The gem is available as open source under the terms of the MIT License.