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 +4 -4
- data/lib/yelp/error.rb +9 -2
- data/lib/yelp/version.rb +1 -1
- data/spec/yelp/error_spec.rb +23 -0
- 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: 56a26261a87144e796fc952682cf9d64a00fafa8
|
4
|
+
data.tar.gz: d6ec8e7c5d4972ae6d7c73ad1e23c3757b2b1e87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae8700880ac6d3ac60126062350109257a340afa3e26ba6e60fb9fc43585804c3844d25cbf56b4ac9d506ffdae5831ec58e0980aa24d7c77f34630e0949fe15b
|
7
|
+
data.tar.gz: 9eaee0908609b12531a04de473d6633c79fd788f480b8f3421a78490e47def9a8717bc848e0d7a750a344995da72b61a4b6b1594b09b1d062869dd05b906adb5
|
data/lib/yelp/error.rb
CHANGED
@@ -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
|
-
|
81
|
-
|
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
|
|
data/lib/yelp/version.rb
CHANGED
data/spec/yelp/error_spec.rb
CHANGED
@@ -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.
|
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-
|
13
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|