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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c10363b23a4abddd239820d39fb1f96dbc0080f6
4
- data.tar.gz: 08cb9e811c67d11728e4f61d43c1354cdf4b818f
3
+ metadata.gz: f1ab53beeb6d13ddd27994af64083a5ec6d27b53
4
+ data.tar.gz: ffc3a68b43d11cd3427b7fae84838178fedbae37
5
5
  SHA512:
6
- metadata.gz: 99c976648f26c260a0a6d4fd326552fea827f0db3c831b6bf14ab433ad5c1ba583793d310084406a71033e89bf2b5f5402ce7309cdf08a3710411fcf85cc3410
7
- data.tar.gz: b4f082467c62a7896ea47876857baeb866701d4935cbb9e94479c4541330f9ab039ed5412f1abff19186d6531f1b1b10e26583c19eef96edafd8ef5c814ad4d3
6
+ metadata.gz: 3eefb1c2d39ea0d3bf7651197c3de830fa59580236f10f270be1826d3fc0436a003663aad7f546841e24cbda0421a15ae62105775387a9fa1073bfff01f11502
7
+ data.tar.gz: f7917ce6d70cab2e90af84b0959fb7c1cb7ff6218a68bfeb4ff5fa6aa5323cb3462fecf5777479058a2d35b533d15363dd9bcfe6a13b05188485a821b4fe7725
@@ -21,11 +21,15 @@ module Courtfinder
21
21
  private
22
22
 
23
23
  def process data
24
- @json = JSON.parse data
25
- unwanted_attributes = ['areas_of_law', 'slug', 'dx_number',
24
+ begin
25
+ @json = JSON.parse data
26
+ unwanted_attributes = ['areas_of_law', 'slug', 'dx_number',
26
27
  'lon', 'lat', 'types', 'number']
27
- @json.each do |court|
28
- unwanted_attributes.each {|attr| court.delete attr }
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
@@ -1,5 +1,5 @@
1
1
  module Courtfinder
2
2
  module Client
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  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
- before { stub_with postcode }
48
+ context 'with valid postcode' do
49
+ before { stub_with postcode }
42
50
 
43
- context 'when given postcode with no spaces' do
44
- let(:postcode) { 'sg80lt' }
51
+ context 'when given postcode with no spaces' do
52
+ let(:postcode) { 'sg80lt' }
45
53
 
46
- it 'should return the court address' do
47
- expect(client.get(postcode)).to eql result
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
- context 'when given postcode with spaces' do
52
- let(:postcode) { 'SG8 0LT' }
59
+ context 'when given postcode with spaces' do
60
+ let(:postcode) { 'SG8 0LT' }
53
61
 
54
- it 'should return the court address' do
55
- expect(client.get(postcode)).to eql result
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
- let(:postcode) { 'fake' }
61
- before { blank_result postcode }
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.2
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-03 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler