WebPay::Mock
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.
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
Copyright (c) 2013- WebPay, Inc.