giphy 2.0.0 → 2.0.1

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: d3c7554e8f3aa5b3d2b541f954b2907a94cbe9ad
4
- data.tar.gz: afd130adf6262c5a74e7313bd8da190a5db606cf
3
+ metadata.gz: 400b63fbcdafa08cc768ee85c1b2525b31d33a50
4
+ data.tar.gz: 181686b337c64a151569de7deb0338f3c627db91
5
5
  SHA512:
6
- metadata.gz: b31939e10d260c2132a180060b376a04488dabd63b3259acae67e24b57caad625f1698b2e6507a16be032655b614fae30dce3d077f73e03e5397beb3e9ffbfe8
7
- data.tar.gz: 4f166904151417744cccfcb519868b9e43fe278689e99ff6ff8011010bf531db1f190a057fb26fed690bad57ec72021e9c01a3c9813319bc8a89516f491bda02
6
+ metadata.gz: 992b85ca64125dda70ffebf884eba03bfc8627321f0faa273f816a4d5321a69b6eae0b7b1d514a8ce0c1c4c48c0b5cd15a93988e534c4e088eafef898947f2ca
7
+ data.tar.gz: 4d9e6af5673327a297eef1ef1268f3849b6f8f67384f3e651298317025f41b936cbb72d5bd4bb59339d3ca8cc2e4ce749e56377a929bdf2c147ba4e6f7eb391a
@@ -19,10 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake", "~> 10.1"
22
+ spec.add_development_dependency "rake", "~> 10.1"
23
23
  spec.add_development_dependency "rspec", "~> 2.14"
24
24
  spec.add_development_dependency "rspec-its", "~> 1.0"
25
25
  spec.add_dependency "faraday", "~> 0.9"
26
+ spec.add_dependency "faraday_middleware"
26
27
  spec.add_dependency "faraday_middleware-parse_oj", "~> 0.3"
27
28
  spec.add_dependency "launchy", "~> 2.4"
28
29
  end
@@ -0,0 +1,5 @@
1
+ module Giphy
2
+ module Errors
3
+ class Unexpected < StandardError ; end
4
+ end
5
+ end
@@ -1,4 +1,5 @@
1
1
  require 'faraday'
2
+ require 'faraday_middleware'
2
3
  require 'faraday_middleware/parse_oj'
3
4
 
4
5
  module Giphy
@@ -27,9 +28,11 @@ module Giphy
27
28
 
28
29
  def connection
29
30
  Faraday.new(url: URL) do |connection|
30
- connection.request :url_encoded
31
+ connection.use FaradayMiddleware::FollowRedirects
32
+ connection.use Faraday::Response::RaiseError
33
+ connection.request :url_encoded
31
34
  connection.response :oj
32
- connection.adapter Faraday.default_adapter
35
+ connection.adapter Faraday.default_adapter
33
36
  end
34
37
  end
35
38
 
@@ -9,6 +9,7 @@ module Giphy
9
9
  end
10
10
 
11
11
  def data
12
+ raise Giphy::Errors::Unexpected unless response.body
12
13
  response.body['data'] || raise(Giphy::Errors::API.new(error))
13
14
  end
14
15
 
@@ -1,3 +1,3 @@
1
1
  module Giphy
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -36,5 +36,14 @@ describe Giphy::Response do
36
36
  expect{ subject.data }.to raise_error Giphy::Errors::API
37
37
  end
38
38
  end
39
+
40
+ context "when response is empty" do
41
+ let(:hash) { nil }
42
+
43
+ it "raises an error and sets its message" do
44
+ expect{ subject.data }.to raise_error Giphy::Errors::Unexpected
45
+ end
46
+ end
47
+
39
48
  end
40
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: giphy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Sogamoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 00:00:00.000000000 Z
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday_middleware
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: faraday_middleware-parse_oj
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +146,7 @@ files:
132
146
  - lib/giphy/configuration.rb
133
147
  - lib/giphy/errors/api.rb
134
148
  - lib/giphy/errors/argument_error.rb
149
+ - lib/giphy/errors/unexpected.rb
135
150
  - lib/giphy/favorite_gif.rb
136
151
  - lib/giphy/flagged_gif.rb
137
152
  - lib/giphy/gif.rb