passfort 0.2.1 → 0.2.2

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
  SHA256:
3
- metadata.gz: aad8b4d28916b07b98a185e5770cdde81ca59353d71284171eb8d4a5fa4c240b
4
- data.tar.gz: ef28d85a96a8c5393deb1b8d4a0ba4ed477897239d43a0d5a73294648ffcea88
3
+ metadata.gz: a294b6d08bf000b4e3c3b76a7509bf5f55da3d0aa6f22e8108dd4f281105f6f4
4
+ data.tar.gz: '0197567a2dae8961d1cf6bed577d17753148b17f5dee37036740acc4885365f1'
5
5
  SHA512:
6
- metadata.gz: cf10cfef404e40a8f935fa4e8b68f2f0a1a27517f5a5f4bda1f82ee98e9df192792089a01cd8f02a6a85f51a35088e0745081945c989d0ff887dfb40fc9c91e9
7
- data.tar.gz: e31d726cf74c4d37b7f9626cf7c647e791ceac7dccfb5d00c49a62cd741249744aea26d7b768f8e740e830eeb303ac2471e771affbefaf7dd47c4f27811ad3e5
6
+ metadata.gz: ef101eaec36d8f92d3702999aca16f1a20b1bd6286b3dcc5c75247a48f10a1d746fa3454e137dd22a9ecf3673b4150d0f5bb18c790b817b9f2400ffe9c615bf3
7
+ data.tar.gz: f36f1c38db985538ea6d97c378dca856c2c864d92de9eefbb41892869dab8518ff4422da02f9b3a3260d47073bd8d3357fa593775ffcdf392773d43dbb35131c
@@ -6,6 +6,11 @@ Unreleased
6
6
 
7
7
  No changes.
8
8
 
9
+ 0.2.2
10
+ ----------
11
+
12
+ - Raise UnparsesableResponseError when the response cannot be parsed as JSON.
13
+
9
14
  0.2.1
10
15
  -----
11
16
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- passfort (0.2.1)
4
+ passfort (0.2.2)
5
5
  activesupport (~> 5.0)
6
6
  excon (~> 0.60)
7
7
 
@@ -22,8 +22,8 @@ GEM
22
22
  safe_yaml (~> 1.0.0)
23
23
  diff-lcs (1.3)
24
24
  excon (0.60.0)
25
- gc_ruboconfig (2.3.4)
26
- rubocop (~> 0.53.0)
25
+ gc_ruboconfig (2.3.5)
26
+ rubocop (~> 0.54.0)
27
27
  rubocop-rspec (~> 1.24)
28
28
  hashdiff (0.3.7)
29
29
  i18n (0.9.5)
@@ -31,7 +31,7 @@ GEM
31
31
  method_source (0.9.0)
32
32
  minitest (5.11.3)
33
33
  parallel (1.12.1)
34
- parser (2.5.0.3)
34
+ parser (2.5.0.4)
35
35
  ast (~> 2.4.0)
36
36
  powerpack (0.1.1)
37
37
  pry (0.11.3)
@@ -54,7 +54,7 @@ GEM
54
54
  rspec-support (3.7.1)
55
55
  rspec_junit_formatter (0.3.0)
56
56
  rspec-core (>= 2, < 4, != 2.12.0)
57
- rubocop (0.53.0)
57
+ rubocop (0.54.0)
58
58
  parallel (~> 1.10)
59
59
  parser (>= 2.5)
60
60
  powerpack (~> 0.1)
@@ -6,6 +6,7 @@ require "passfort/errors/chargeable_limit_reached_error"
6
6
  require "passfort/errors/invalid_api_key_error"
7
7
  require "passfort/errors/invalid_input_data_error"
8
8
  require "passfort/errors/request_error"
9
+ require "passfort/errors/unparseable_response_error"
9
10
 
10
11
  module Passfort
11
12
  module Errors
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Passfort
4
+ module Errors
5
+ class UnparseableResponseError < APIError
6
+ def initialize(*args)
7
+ super("Unparseable response body", *args)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -18,6 +18,8 @@ module Passfort
18
18
  body = JSON.parse(response.body)
19
19
  handle_error(response, body)
20
20
  body
21
+ rescue JSON::ParserError
22
+ raise Passfort::Errors::UnparseableResponseError.new([], response)
21
23
  end
22
24
 
23
25
  def post(path, body:)
@@ -29,6 +31,8 @@ module Passfort
29
31
  body = JSON.parse(response.body)
30
32
  handle_error(response, body)
31
33
  body
34
+ rescue JSON::ParserError
35
+ raise Passfort::Errors::UnparseableResponseError.new([], response)
32
36
  end
33
37
 
34
38
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Passfort
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -49,6 +49,13 @@ RSpec.describe Passfort::Http do
49
49
  it { is_expected.to raise_error(error_class) }
50
50
  end
51
51
 
52
+ context "when returning a response that can't be parsed as JSON" do
53
+ let(:body) { "<html><body><h1>something that isn't json</h1></body></html>" }
54
+ let(:error_class) { Passfort::Errors::UnparseableResponseError }
55
+
56
+ it { is_expected.to raise_error(error_class) }
57
+ end
58
+
52
59
  context "when returning a successful result" do
53
60
  let(:result) { subject.call }
54
61
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passfort
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-19 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -136,6 +136,7 @@ files:
136
136
  - lib/passfort/errors/invalid_input_data_error.rb
137
137
  - lib/passfort/errors/request_error.rb
138
138
  - lib/passfort/errors/unknown_api_error.rb
139
+ - lib/passfort/errors/unparseable_response_error.rb
139
140
  - lib/passfort/http.rb
140
141
  - lib/passfort/resource.rb
141
142
  - lib/passfort/resource/base.rb