courtfinder-client 0.0.3 → 0.0.4
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 -2
- data/lib/courtfinder/client/version.rb +1 -1
- data/spec/client_spec.rb +14 -2
- 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: c092f0de666d8f72bab99f87c61635893b340350
|
4
|
+
data.tar.gz: ca3ff8792f0fe3736a1167732ffbc02af8d03d94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b31ff1220c909c1733d919e1e2f5bd648b22a351954edbf8956cec874320ebc479cd7a4722e24b70f99d90ca2a6644e51b2cd55cab6f0d65f89c8534c7188b37
|
7
|
+
data.tar.gz: deb5a21818d88feaa79176768e35d4eade1e814621ad5ca831ca7eab759411c052c9024a5000c5659652224ce5b780886c859f9cc9c6f62c584ec4b0c92b8bcc
|
data/lib/courtfinder/client.rb
CHANGED
@@ -10,8 +10,14 @@ module Courtfinder
|
|
10
10
|
PATH='/search/results.json?area_of_law=Housing+possession&postcode='
|
11
11
|
|
12
12
|
def get postcode
|
13
|
-
conn =
|
14
|
-
|
13
|
+
conn = nil
|
14
|
+
begin
|
15
|
+
endpoint = "#{Courtfinder::SERVER}#{PATH}#{URI.escape(postcode)}"
|
16
|
+
Timeout::timeout(1.5) { conn = Faraday.get endpoint }
|
17
|
+
process conn.body
|
18
|
+
rescue Faraday::TimeoutError
|
19
|
+
[]
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
23
|
def empty?
|
data/spec/client_spec.rb
CHANGED
@@ -46,10 +46,9 @@ describe Courtfinder::Client::HousingPossession do
|
|
46
46
|
|
47
47
|
describe '.get' do
|
48
48
|
context 'with valid postcode' do
|
49
|
-
before { stub_with postcode }
|
50
|
-
|
51
49
|
context 'when given postcode with no spaces' do
|
52
50
|
let(:postcode) { 'sg80lt' }
|
51
|
+
before { stub_with postcode }
|
53
52
|
|
54
53
|
it 'should return the court address' do
|
55
54
|
expect(client.get(postcode)).to eql result
|
@@ -58,11 +57,24 @@ describe Courtfinder::Client::HousingPossession do
|
|
58
57
|
|
59
58
|
context 'when given postcode with spaces' do
|
60
59
|
let(:postcode) { 'SG8 0LT' }
|
60
|
+
before { stub_with postcode }
|
61
61
|
|
62
62
|
it 'should return the court address' do
|
63
63
|
expect(client.get(postcode)).to eql result
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
context 'when a timeout occurs' do
|
68
|
+
let(:postcode) { 'SG8 0LT' }
|
69
|
+
before do
|
70
|
+
stub_request(:get, full_url(postcode))
|
71
|
+
.to_raise(Timeout::Error)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should return a blank array' do
|
75
|
+
expect(client.get(full_url(postcode))).to eql []
|
76
|
+
end
|
77
|
+
end
|
66
78
|
end
|
67
79
|
|
68
80
|
context 'when invalid postcode is provided' do
|
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.4
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|