courtfinder-client 0.0.2 → 0.0.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 +4 -4
- data/lib/courtfinder/client.rb +8 -4
- data/lib/courtfinder/client/version.rb +1 -1
- data/spec/client_spec.rb +28 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1ab53beeb6d13ddd27994af64083a5ec6d27b53
|
4
|
+
data.tar.gz: ffc3a68b43d11cd3427b7fae84838178fedbae37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3eefb1c2d39ea0d3bf7651197c3de830fa59580236f10f270be1826d3fc0436a003663aad7f546841e24cbda0421a15ae62105775387a9fa1073bfff01f11502
|
7
|
+
data.tar.gz: f7917ce6d70cab2e90af84b0959fb7c1cb7ff6218a68bfeb4ff5fa6aa5323cb3462fecf5777479058a2d35b533d15363dd9bcfe6a13b05188485a821b4fe7725
|
data/lib/courtfinder/client.rb
CHANGED
@@ -21,11 +21,15 @@ module Courtfinder
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def process data
|
24
|
-
|
25
|
-
|
24
|
+
begin
|
25
|
+
@json = JSON.parse data
|
26
|
+
unwanted_attributes = ['areas_of_law', 'slug', 'dx_number',
|
26
27
|
'lon', 'lat', 'types', 'number']
|
27
|
-
|
28
|
-
|
28
|
+
@json.each do |court|
|
29
|
+
unwanted_attributes.each {|attr| court.delete attr }
|
30
|
+
end
|
31
|
+
rescue JSON::ParserError
|
32
|
+
@json = []
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -37,32 +37,46 @@ describe Courtfinder::Client::HousingPossession do
|
|
37
37
|
:headers => {})
|
38
38
|
end
|
39
39
|
|
40
|
+
def error_result postcode
|
41
|
+
stub_request(:get, full_url(postcode))
|
42
|
+
.to_return(:status => 404,
|
43
|
+
:body => '',
|
44
|
+
:headers => {})
|
45
|
+
end
|
46
|
+
|
40
47
|
describe '.get' do
|
41
|
-
|
48
|
+
context 'with valid postcode' do
|
49
|
+
before { stub_with postcode }
|
42
50
|
|
43
|
-
|
44
|
-
|
51
|
+
context 'when given postcode with no spaces' do
|
52
|
+
let(:postcode) { 'sg80lt' }
|
45
53
|
|
46
|
-
|
47
|
-
|
54
|
+
it 'should return the court address' do
|
55
|
+
expect(client.get(postcode)).to eql result
|
56
|
+
end
|
48
57
|
end
|
49
|
-
end
|
50
58
|
|
51
|
-
|
52
|
-
|
59
|
+
context 'when given postcode with spaces' do
|
60
|
+
let(:postcode) { 'SG8 0LT' }
|
53
61
|
|
54
|
-
|
55
|
-
|
62
|
+
it 'should return the court address' do
|
63
|
+
expect(client.get(postcode)).to eql result
|
64
|
+
end
|
56
65
|
end
|
57
66
|
end
|
58
67
|
|
59
68
|
context 'when invalid postcode is provided' do
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
it 'should return an error' do
|
69
|
+
it 'should return a blank array' do
|
70
|
+
postcode = 'fake'
|
71
|
+
blank_result postcode
|
64
72
|
expect(client.get(postcode)).to eql []
|
65
73
|
end
|
74
|
+
|
75
|
+
it 'should not raise an error' do
|
76
|
+
postcode = 'break'
|
77
|
+
error_result postcode
|
78
|
+
expect { client.get(postcode) }.not_to raise_error
|
79
|
+
end
|
66
80
|
end
|
67
81
|
end
|
68
82
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: courtfinder-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksandar Simić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|