Socket
Book a DemoInstallSign in
Socket

webpay-mock

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpay-mock

0.3.0
bundlerRubygems
Version published
Maintainers
2
Created
Source

WebPay::Mock Build Status

WebPay::Mock helps development of WebPay client applications.

This generates a response object from request parameters, and wraps WebMock gem for easy end-to-end testing against webpay API server.

Installation

Add this line to your application's Gemfile:

gem 'webpay-mock'

And then execute:

$ bundle

Or install it yourself as:

$ gem install webpay-mock

Usage

RSpec

In spec_helper.rb,

require 'webpay/mock'

RSpec.configure do |c|
  c.include WebPay::Mock::WebMockWrapper
end

In your spec file,

let(:params) { { amount: 1000, currency: 'jpy', card: 'tok_xxxxxxxxx', description: 'test charge' } }
let!(:response) { webpay_stub(:charges, :create, params: params) }

specify { expect(webpay.charge.create(params).id).to eq response['id'] }

See our test cases for more examples.

Testing error responses

Just return an error by type.

webpay_stub(:charges, :create, error: :card_error, params: params)

Error kinds are:

  • bad_request (400)
  • unauthorized (401)
  • card_error (402)
  • not_found (404)
  • internal_server_error (500)

Specify all fields to test a specific error.

webpay_stub(:charges, :create, params: params, response: card_error(
    message: "You must provide the card which is not expired",
    caused_by: "buyer",
    param: "exp_month",
    code: "invalid_expiry_month"
    ))

For up-to-date details about error structure, see API error document on our website.

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Fixed bugs and new features must be tested.

License

The MIT License (MIT)

Copyright (c) 2013- WebPay, Inc.

FAQs

Package last updated on 07 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.