yelp 2.1.2 → 2.1.3

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: 1d7b25abb238f773d41b4c56348c28cf1dd8875f
4
- data.tar.gz: c36ca4257db000965d16861e1457e49b3d0e4414
3
+ metadata.gz: 56a26261a87144e796fc952682cf9d64a00fafa8
4
+ data.tar.gz: d6ec8e7c5d4972ae6d7c73ad1e23c3757b2b1e87
5
5
  SHA512:
6
- metadata.gz: 2c21ab0c24f81659212d35bb298e6155dd1fbe6efff623bd5fdcb0de76e67fd5a597bbfdf71f4c8d53bdd6fccc0cf789119b6ba9d6e5b02b1e5c52efe03e8003
7
- data.tar.gz: b7bef05e2332c99bf2842d069086255598610907395ab860d1a285f6635fde274f2d792dc88e08116e2ddd199c5f05e571bcb5b8203bb2b0059903b1fd4cc151
6
+ metadata.gz: ae8700880ac6d3ac60126062350109257a340afa3e26ba6e60fb9fc43585804c3844d25cbf56b4ac9d506ffdae5831ec58e0980aa24d7c77f34630e0949fe15b
7
+ data.tar.gz: 9eaee0908609b12531a04de473d6633c79fd788f480b8f3421a78490e47def9a8717bc848e0d7a750a344995da72b61a4b6b1594b09b1d062869dd05b906adb5
@@ -47,6 +47,7 @@ module Yelp
47
47
 
48
48
  class Base < StandardError
49
49
  def initialize(msg,error=nil)
50
+ super(msg)
50
51
  end
51
52
  end
52
53
 
@@ -76,9 +77,15 @@ module Yelp
76
77
  end
77
78
 
78
79
  class InvalidParameter < Base
80
+ attr_reader :text, :field
81
+
79
82
  def initialize(msg='One or more parameters were invalid', error=nil)
80
- msg = msg + ': ' + error['field'] unless error.nil?
81
- super
83
+ unless error.nil?
84
+ @text = error['text']
85
+ @field = error['field']
86
+ msg = msg + ': ' + @field
87
+ end
88
+ super(msg,error)
82
89
  end
83
90
  end
84
91
 
@@ -1,3 +1,3 @@
1
1
  module Yelp
2
- VERSION = "2.1.2"
2
+ VERSION = "2.1.3"
3
3
  end
@@ -18,4 +18,27 @@ describe Yelp::Error do
18
18
  }.to raise_error(Yelp::Error::InternalError)
19
19
  end
20
20
  end
21
+
22
+ context 'invalid parameter' do
23
+ let(:response_body) { "{\"error\": {\"text\": \"One or more parameters are invalid in request\", \"id\": \"INVALID_PARAMETER\", \"field\": \"oauth_token\"}}" }
24
+ let(:bad_response) { double('response', status: 400, body: response_body) }
25
+
26
+ it 'should raise an invalid response error' do
27
+ expect {
28
+ Yelp::Error.check_for_error(bad_response)
29
+ }.to raise_error(Yelp::Error::InvalidParameter)
30
+ end
31
+
32
+ it 'should expose the field parameter' do
33
+ begin
34
+ Yelp::Error.check_for_error(bad_response)
35
+ rescue Yelp::Error::InvalidParameter => e
36
+ # verifies that StandardError message attribute is available
37
+ expect(e.message).to eq("One or more parameters are invalid in request: oauth_token")
38
+ # verifies that we can get access to the specific field that was invalid
39
+ expect(e.field).to eq("oauth_token")
40
+ end
41
+ end
42
+
43
+ end
21
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yelp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomer Elmalem
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-03-22 00:00:00.000000000 Z
13
+ date: 2016-07-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler