govuk-pay-api-client 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d600eb9b82d846f3ab8c177e38e9f4a455300311
4
- data.tar.gz: 83b303513d1d7073a69deb2c9ff4e48b318de37b
3
+ metadata.gz: e732d71a1639aade11e5fd80d94d40cc323d7c8e
4
+ data.tar.gz: 6427e2344c1f0c97b6e31844dc7d5781940cbae5
5
5
  SHA512:
6
- metadata.gz: 2bd1c3d5f452848ad7ef5c99458f9faff6c9dd681a74c29ebd76dae5840a578285c16cded530b979f8310a189b2655cbe462858715c7d26d1254b074e19e5dca
7
- data.tar.gz: 68a178b1773105117d4deb61ddda03243dc4e265a235b29b8a07b8746d0e39a8c8609c873b60128be3aae806665872c313d23b904ee5941affe2509a62a6ab94
6
+ metadata.gz: ce803a91eb8e68cf276c0900406f7b05a1ecaef29bc6e0b66eb3d6a797a20f732c531e8c7409cc23d2ce55e9b99703a7f88e61f5c6921def29619aa54a231b78
7
+ data.tar.gz: 3256f874884a02c3664ad920083ac1baa55d3861c63a3614cca5565d31ed41762d5b5e4480b3536bc18cabb9b4aded2764984b9f78123de1dfcde011e6d3bb0c
data/README.md CHANGED
@@ -73,31 +73,6 @@ Or install it yourself as:
73
73
  Run `bundle rake` in the gem source directory for a full set of specs,
74
74
  mutation tests and rubocop checks.
75
75
 
76
- ### Shared examples
77
-
78
- The gem can install a set of shared examples in your app that will stub
79
- a sensible set of API calls using Excon’s stubbing functionality. To
80
- install these, install the gem, make sure you have the `spec/support`
81
- subdirectory then run:
82
-
83
- ```ruby
84
- bundle exec rake govuk_pay_api_client:install_shared_examples
85
- ```
86
-
87
- This will install `spec/support/shared_examples_for_govpay.rb`.
88
-
89
- Lastly, add these lines to `spec/rails_helper`:
90
-
91
- ```ruby
92
- config.before(:all) do
93
- Excon.defaults[:mock] = true
94
- end
95
-
96
- config.after(:each) do
97
- Excon.stubs.clear
98
- end
99
- ```
100
-
101
76
  ## Contributing
102
77
 
103
78
  Fork, then clone the repo:
@@ -1,3 +1,3 @@
1
1
  module GovukPayApiClient
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk-pay-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Tyree
@@ -190,8 +190,6 @@ files:
190
190
  - lib/govuk_pay_api_client/version.rb
191
191
  - lib/tasks/mutant.rake
192
192
  - lib/tasks/rubocop.rake
193
- - lib/tasks/spec_setup.rake
194
- - shared_examples/shared_examples_for_govpay.rb
195
193
  homepage: https://github.com/ministryofjustice/govuk-pay-api-client/
196
194
  licenses:
197
195
  - MIT
@@ -1,11 +0,0 @@
1
- namespace :govuk_pay_api_client do
2
- desc 'Copy the shared examples for govuk pay api rspec testing'
3
- task :install_shared_examples
4
- source = File.join(
5
- Gem.loaded_specs['govuk-pay-api-client'].full_gem_path,
6
- 'shared_examples',
7
- 'shared_examples_for_govpay.rb'
8
- )
9
- target = File.join(Rails.root, 'spec', 'support', 'shared_examples_for_govpay.rb')
10
- FileUtils.cp_r source, target
11
- end
@@ -1,164 +0,0 @@
1
- module GovpayExample
2
- module Mocks
3
- def a_create_payment_timeout
4
- class_double(Excon, 'create payment timeout').tap { |ex|
5
- expect(ex).to receive(:post).and_raise(Excon::Errors::Timeout)
6
- }
7
- end
8
-
9
- def a_payment_status_timeout
10
- class_double(Excon, 'create payment timeout').tap { |ex|
11
- expect(ex).to receive(:get).and_raise(Excon::Errors::Timeout)
12
- }
13
- end
14
- end
15
-
16
- module Responses
17
- def initial_payment_response(payment_id = 'rmpaurrjuehgpvtqg997bt50f')
18
- {
19
- 'payment_id' => payment_id,
20
- 'payment_provider' => 'sandbox',
21
- 'amount' => 2000,
22
- 'state' => {
23
- 'status' => 'created',
24
- 'finished' => false
25
- },
26
- 'description' => 'TC/2016/00001 - Lodgement Fee',
27
- 'return_url' => 'https://www-integration-2.pymnt.uk/liabilities/960eb61a-a592-4e79-a5f8-c35cde24352a/post_pay',
28
- 'reference' => '7G20160718180649',
29
- 'created_date' => '2016-07-18T17:06:53.172Z',
30
- '_links' => {
31
- 'self' => {
32
- 'href' => 'https://publicapi.pymnt.uk/v1/payments/rmpaurrjuehgpvtqg997bt50fm',
33
- 'method' => 'GET'
34
- },
35
- 'next_url' => {
36
- 'href' => 'https://www-integration-2.pymnt.uk/secure/94b35000-37f2-44e6-a2f5-c0193ca1e98a',
37
- 'method' => 'GET'
38
- }
39
- }
40
- }.to_json
41
- end
42
-
43
- def post_pay_response
44
- {
45
- 'payment_id' => 'oio28jhr7mj6rqc9g12pff2i44',
46
- 'payment_provider' => 'sandbox', 'amount' => 2000,
47
- 'state' => {
48
- 'status' => 'success',
49
- 'finished' => true
50
- },
51
- 'description' => 'TC/2016/00001 - Lodgement Fee',
52
- 'return_url' => 'https://www-integration-2.pymnt.uk/liabilities/7f475fde-b509-4612-bffb-e2dac0066f4c/post_pay',
53
- 'reference' => '7G20160725115358',
54
- 'created_date' => '2016-07-25T10:54:00.294Z',
55
- '_links' => {
56
- 'self' => {
57
- 'href' => 'https://publicapi.pymnt.uk/v1/payments/oio28jhr7mj6rqc9g12pff2i44',
58
- 'method' => 'GET'
59
- },
60
- 'next_url' => nil,
61
- 'next_url_post' => nil,
62
- 'events' => {
63
- 'href' => 'https://publicapi.pymnt.uk/v1/payments/oio28jhr7mj6rqc9g12pff2i44/events',
64
- 'method' => 'GET'
65
- },
66
- 'cancel' => nil
67
- }
68
- }.to_json
69
- end
70
- end
71
- end
72
-
73
- RSpec.shared_examples 'govpay payment response' do |fee, govpay_payment_id|
74
- include GovpayExample::Responses
75
-
76
- let(:request_body) {
77
- {
78
- return_url: 'the_return_url',
79
- description: fee.description,
80
- reference: fee.govpay_reference,
81
- amount: fee.amount
82
- }.to_json
83
- }
84
-
85
- before do
86
- Excon.stub(
87
- {
88
- method: :post,
89
- host: 'govpay-test.dsd.io',
90
- body: request_body,
91
- path: '/payments'
92
- },
93
- status: 201, body: initial_payment_response(govpay_payment_id)
94
- )
95
-
96
- Excon.stub(
97
- {
98
- method: :get,
99
- host: 'govpay-test.dsd.io',
100
- path: "/payments/#{govpay_payment_id}"
101
- },
102
- status: 200, body: post_pay_response
103
- )
104
- end
105
- end
106
-
107
- RSpec.shared_examples 'govpay returns a 404' do |fee|
108
-
109
- let(:request_body) {
110
- {
111
- return_url: 'the_return_url',
112
- description: fee.description,
113
- reference: fee.govpay_reference,
114
- amount: fee.amount
115
- }.to_json
116
- }
117
-
118
- before do
119
- Excon.stub(
120
- {
121
- method: :post,
122
- host: 'govpay-test.dsd.io',
123
- body: request_body,
124
- path: '/payments'
125
- },
126
- status: 404
127
- )
128
- end
129
- end
130
-
131
- RSpec.shared_examples 'govpay post_pay returns a 500' do |govpay_payment_id|
132
- before do
133
- Excon.stub(
134
- {
135
- method: :get,
136
- host: 'govpay-test.dsd.io',
137
- path: "/payments/#{govpay_payment_id}"
138
- },
139
- status: 500, body: '{"message":"Govpay is not working"}'
140
- )
141
- end
142
- end
143
-
144
- RSpec.shared_examples 'govpay payment status times out' do
145
- include GovpayExample::Responses
146
- include GovpayExample::Mocks
147
-
148
- before do
149
- expect(Excon).to receive(:new).
150
- and_return(
151
- a_payment_status_timeout
152
- )
153
- end
154
- end
155
-
156
- RSpec.shared_examples 'govpay create payment times out' do
157
- include GovpayExample::Responses
158
- include GovpayExample::Mocks
159
-
160
- before do
161
- expect(Excon).to receive(:new).
162
- and_return(a_create_payment_timeout)
163
- end
164
- end