courtfinder-client 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1ab53beeb6d13ddd27994af64083a5ec6d27b53
4
- data.tar.gz: ffc3a68b43d11cd3427b7fae84838178fedbae37
3
+ metadata.gz: c092f0de666d8f72bab99f87c61635893b340350
4
+ data.tar.gz: ca3ff8792f0fe3736a1167732ffbc02af8d03d94
5
5
  SHA512:
6
- metadata.gz: 3eefb1c2d39ea0d3bf7651197c3de830fa59580236f10f270be1826d3fc0436a003663aad7f546841e24cbda0421a15ae62105775387a9fa1073bfff01f11502
7
- data.tar.gz: f7917ce6d70cab2e90af84b0959fb7c1cb7ff6218a68bfeb4ff5fa6aa5323cb3462fecf5777479058a2d35b533d15363dd9bcfe6a13b05188485a821b4fe7725
6
+ metadata.gz: b31ff1220c909c1733d919e1e2f5bd648b22a351954edbf8956cec874320ebc479cd7a4722e24b70f99d90ca2a6644e51b2cd55cab6f0d65f89c8534c7188b37
7
+ data.tar.gz: deb5a21818d88feaa79176768e35d4eade1e814621ad5ca831ca7eab759411c052c9024a5000c5659652224ce5b780886c859f9cc9c6f62c584ec4b0c92b8bcc
@@ -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 = Faraday.get "#{Courtfinder::SERVER}#{PATH}#{URI.escape(postcode)}"
14
- process conn.body
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?
@@ -1,5 +1,5 @@
1
1
  module Courtfinder
2
2
  module Client
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
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.3
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-08 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler