glimr-api-client 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -23
- data/lib/glimr_api_client.rb +0 -1
- data/lib/glimr_api_client/version.rb +1 -1
- metadata +2 -5
- data/lib/glimr_api_client/railtie.rb +0 -11
- data/lib/tasks/spec_setup.rake +0 -11
- data/shared_examples/shared_examples_for_glimr.rb +0 -212
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d090c08e733fa1980327591baf348705a15ef1a
|
4
|
+
data.tar.gz: 7f0fc6d4e7940a860a92e7b551520a29c7692b35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f3bd5682bec9f2c78a9c299b22847532d93f0dd35c2a43891d9e9b3a4811fb99b117f232f4dde2a0cf93c274e229ab091a3c90c87a7b5b5aab05998c272ca9c
|
7
|
+
data.tar.gz: 489f72535fda5e5e17f8ea2a8040690df0c0bc23091bdb1e31625ba8fcb02d0346865f0f25ba67a245b8afa65f0ba0877befa9c7db026a98b70ebe7957c0999d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -76,30 +76,11 @@ $ gem install glimr-api-client
|
|
76
76
|
Run `bundle rake` in the gem source directory for a full set of specs,
|
77
77
|
mutation tests and rubocop checks.
|
78
78
|
|
79
|
-
###
|
79
|
+
### In an application
|
80
80
|
|
81
|
-
|
82
|
-
a
|
83
|
-
|
84
|
-
subdirectory then run:
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
bundle exec rake rake glimr_api_client:install_shared_examples
|
88
|
-
```
|
89
|
-
|
90
|
-
This will install `spec/support/shared_examples_for_glimr.rb`.
|
91
|
-
|
92
|
-
Lastly, add these lines to `spec/rails_helper`:
|
93
|
-
|
94
|
-
```ruby
|
95
|
-
config.before(:all) do
|
96
|
-
Excon.defaults[:mock] = true
|
97
|
-
end
|
98
|
-
|
99
|
-
config.after(:each) do
|
100
|
-
Excon.stubs.clear
|
101
|
-
end
|
102
|
-
```
|
81
|
+
Examples of how this gem might be used can be found in the specs. There
|
82
|
+
is also a set of RSpec shared examples that can be copied and modified.
|
83
|
+
These can be found in `spec/suppport/shared_examples_for_govpay.rb`.
|
103
84
|
|
104
85
|
## Contributing
|
105
86
|
|
@@ -113,6 +94,7 @@ Make sure the tests pass:
|
|
113
94
|
|
114
95
|
```bash
|
115
96
|
bundle
|
97
|
+
bundle db:setup
|
116
98
|
bundle exec rake
|
117
99
|
```
|
118
100
|
|
data/lib/glimr_api_client.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimr-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Tyree
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -201,13 +201,10 @@ files:
|
|
201
201
|
- lib/glimr_api_client/api.rb
|
202
202
|
- lib/glimr_api_client/available.rb
|
203
203
|
- lib/glimr_api_client/case.rb
|
204
|
-
- lib/glimr_api_client/railtie.rb
|
205
204
|
- lib/glimr_api_client/update.rb
|
206
205
|
- lib/glimr_api_client/version.rb
|
207
206
|
- lib/tasks/mutant.rake
|
208
207
|
- lib/tasks/rubocop.rake
|
209
|
-
- lib/tasks/spec_setup.rake
|
210
|
-
- shared_examples/shared_examples_for_glimr.rb
|
211
208
|
homepage: https://github.com/ministryofjustice/glimr-api-client
|
212
209
|
licenses:
|
213
210
|
- MIT
|
data/lib/tasks/spec_setup.rake
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
namespace :glimr_api_client do
|
2
|
-
desc 'Copy the shared examples for glimr rspec testing'
|
3
|
-
task :install_shared_examples
|
4
|
-
source = File.join(
|
5
|
-
Gem.loaded_specs['glimr-api-client'].full_gem_path,
|
6
|
-
'shared_examples',
|
7
|
-
'shared_examples_for_glimr.rb'
|
8
|
-
)
|
9
|
-
target = File.join(Rails.root, 'spec', 'support', 'shared_examples_for_glimr.rb')
|
10
|
-
FileUtils.cp_r source, target
|
11
|
-
end
|
@@ -1,212 +0,0 @@
|
|
1
|
-
RSpec.shared_examples 'glimr availability request' do |glimr_response|
|
2
|
-
before do
|
3
|
-
Excon.stub(
|
4
|
-
{ host: 'glimr-test.dsd.io', path: '/glimravailable' },
|
5
|
-
status: 200, body: glimr_response.to_json
|
6
|
-
)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
RSpec.shared_examples 'glimr availability request returns a 500' do
|
11
|
-
before do
|
12
|
-
Excon.stub(
|
13
|
-
{ host: 'glimr-test.dsd.io', path: '/glimravailable' },
|
14
|
-
status: 500
|
15
|
-
)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
RSpec.shared_examples 'service is not available' do
|
20
|
-
scenario do
|
21
|
-
visit '/'
|
22
|
-
expect(page).not_to have_text('Start now')
|
23
|
-
expect(page).to have_text('The service is currently unavailable')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
RSpec.shared_examples 'generic glimr response' do |case_number, _confirmation_code, status, glimr_response|
|
28
|
-
before do
|
29
|
-
Excon.stub(
|
30
|
-
{
|
31
|
-
host: 'glimr-test.dsd.io',
|
32
|
-
body: /caseNumber=#{CGI.escape(case_number)}/,
|
33
|
-
path: '/requestpayablecasefees'
|
34
|
-
},
|
35
|
-
status: status, body: glimr_response.to_json
|
36
|
-
)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
RSpec.shared_examples 'case not found' do
|
41
|
-
before do
|
42
|
-
Excon.stub(
|
43
|
-
{
|
44
|
-
host: 'glimr-test.dsd.io',
|
45
|
-
path: '/requestpayablecasefees'
|
46
|
-
},
|
47
|
-
status: 404
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
RSpec.shared_examples 'no new fees are due' do |case_number, _confirmation_code|
|
53
|
-
let(:response_body) {
|
54
|
-
{
|
55
|
-
'jurisdictionId' => 8,
|
56
|
-
'tribunalCaseId' => 60_029,
|
57
|
-
'caseTitle' => 'You vs HM Revenue & Customs',
|
58
|
-
'feeLiabilities' => []
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
before do
|
63
|
-
Excon.stub(
|
64
|
-
{
|
65
|
-
host: 'glimr-test.dsd.io',
|
66
|
-
body: /caseNumber=#{CGI.escape(case_number)}/,
|
67
|
-
path: '/requestpayablecasefees'
|
68
|
-
},
|
69
|
-
status: 200, body: response_body.to_json
|
70
|
-
)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
RSpec.shared_examples 'a case fee of £20 is due' do |case_number, _confirmation_code|
|
75
|
-
let(:response_body) {
|
76
|
-
{
|
77
|
-
'jurisdictionId' => 8,
|
78
|
-
'tribunalCaseId' => 60_029,
|
79
|
-
'caseTitle' => 'You vs HM Revenue & Customs',
|
80
|
-
'feeLiabilities' =>
|
81
|
-
[{ 'feeLiabilityId' => '7',
|
82
|
-
'onlineFeeTypeDescription' => 'Lodgement Fee',
|
83
|
-
'payableWithUnclearedInPence' => '2000' }]
|
84
|
-
}.to_json
|
85
|
-
}
|
86
|
-
|
87
|
-
before do
|
88
|
-
Excon.stub(
|
89
|
-
{
|
90
|
-
method: :post,
|
91
|
-
host: 'glimr-test.dsd.io',
|
92
|
-
body: /caseNumber=#{CGI.escape(case_number)}&jurisdictionId=8/,
|
93
|
-
path: '/requestpayablecasefees'
|
94
|
-
},
|
95
|
-
status: 200, body: response_body
|
96
|
-
)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
RSpec.shared_examples 'no fees then a £20 fee' do |case_number, _confirmation_code|
|
101
|
-
let(:no_fees) {
|
102
|
-
{
|
103
|
-
'jurisdictionId' => 8,
|
104
|
-
'tribunalCaseId' => 60_029,
|
105
|
-
'caseTitle' => 'You vs HM Revenue & Customs',
|
106
|
-
'feeLiabilities' => []
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
let(:twenty_pound_fee) {
|
111
|
-
{
|
112
|
-
'jurisdictionId' => 8,
|
113
|
-
'tribunalCaseId' => 60_029,
|
114
|
-
'caseTitle' => 'You vs HM Revenue & Customs',
|
115
|
-
'feeLiabilities' =>
|
116
|
-
[{ 'feeLiabilityId' => 7,
|
117
|
-
'onlineFeeTypeDescription' => 'Lodgement Fee',
|
118
|
-
'payableWithUnclearedInPence' => 2000 }]
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
before do
|
123
|
-
Excon.stub(
|
124
|
-
{
|
125
|
-
method: :post,
|
126
|
-
host: 'glimr-test.dsd.io',
|
127
|
-
body: /caseNumber=#{CGI.escape(case_number)}/,
|
128
|
-
path: '/requestpayablecasefees'
|
129
|
-
},
|
130
|
-
status: 200, body: no_fees.to_json
|
131
|
-
)
|
132
|
-
|
133
|
-
Excon.stub(
|
134
|
-
{
|
135
|
-
method: :post,
|
136
|
-
host: 'glimr-test.dsd.io',
|
137
|
-
body: /caseNumber=#{CGI.escape(case_number)}/,
|
138
|
-
path: '/requestpayablecasefees'
|
139
|
-
},
|
140
|
-
status: 200, body: twenty_pound_fee.to_json
|
141
|
-
)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
RSpec.shared_examples 'report payment taken to glimr' do |req_body|
|
146
|
-
let(:paymenttaken_response) {
|
147
|
-
{
|
148
|
-
feeLiabilityId: 1234,
|
149
|
-
feeTransactionId: 1234,
|
150
|
-
paidAmountInPence: 9999
|
151
|
-
}
|
152
|
-
}
|
153
|
-
|
154
|
-
before do
|
155
|
-
Excon.stub(
|
156
|
-
{
|
157
|
-
method: :post,
|
158
|
-
host: 'glimr-test.dsd.io',
|
159
|
-
body: req_body,
|
160
|
-
path: '/paymenttaken'
|
161
|
-
},
|
162
|
-
status: 200, body: paymenttaken_response.to_json
|
163
|
-
)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
RSpec.shared_examples 'glimr fee_paid returns a 500' do
|
168
|
-
before do
|
169
|
-
Excon.stub(
|
170
|
-
{
|
171
|
-
method: :post,
|
172
|
-
host: 'glimr-test.dsd.io',
|
173
|
-
path: '/paymenttaken'
|
174
|
-
},
|
175
|
-
status: 500
|
176
|
-
)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
RSpec.shared_examples 'glimr times out' do
|
181
|
-
let(:glimr_check) {
|
182
|
-
class_double(Excon, 'glimr availability')
|
183
|
-
}
|
184
|
-
|
185
|
-
before do
|
186
|
-
expect(glimr_check).
|
187
|
-
to receive(:post).
|
188
|
-
with(path: '/glimravailable', body: '').
|
189
|
-
and_raise(Excon::Errors::Timeout)
|
190
|
-
|
191
|
-
expect(Excon).to receive(:new).
|
192
|
-
with(Rails.configuration.glimr_api_url, anything).
|
193
|
-
and_return(glimr_check)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
RSpec.shared_examples 'glimr has a socket error' do
|
198
|
-
let(:glimr_check) {
|
199
|
-
class_double(Excon, 'glimr availability')
|
200
|
-
}
|
201
|
-
|
202
|
-
before do
|
203
|
-
expect(glimr_check).
|
204
|
-
to receive(:post).
|
205
|
-
with(path: '/glimravailable', body: '').
|
206
|
-
and_raise(Excon::Errors::SocketError)
|
207
|
-
|
208
|
-
expect(Excon).to receive(:new).
|
209
|
-
with('https://glimr-test.dsd.io', anything).
|
210
|
-
and_return(glimr_check)
|
211
|
-
end
|
212
|
-
end
|