faraday 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.
- data/VERSION +1 -1
- data/faraday.gemspec +3 -3
- data/lib/faraday/adapter/patron.rb +1 -1
- data/lib/faraday/adapter/typhoeus.rb +1 -1
- data/lib/faraday/request/active_support_json.rb +2 -1
- data/lib/faraday/request/yajl.rb +1 -1
- data/lib/faraday/response.rb +1 -0
- data/lib/faraday/response/active_support_json.rb +2 -1
- data/lib/faraday/response/yajl.rb +1 -1
- data/test/response_middleware_test.rb +26 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/faraday.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{faraday}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["rick"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-06}
|
13
13
|
s.description = %q{HTTP/REST API client library with pluggable components}
|
14
14
|
s.email = %q{technoweenie@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/faraday/request/yajl.rb
CHANGED
data/lib/faraday/response.rb
CHANGED
@@ -3,6 +3,7 @@ module Faraday
|
|
3
3
|
begin
|
4
4
|
if !defined?(ActiveSupport::JSON)
|
5
5
|
require 'active_support'
|
6
|
+
ActiveSupport::JSON
|
6
7
|
end
|
7
8
|
|
8
9
|
def self.register_on_complete(env)
|
@@ -10,7 +11,7 @@ module Faraday
|
|
10
11
|
finished_env[:body] = ActiveSupport::JSON.decode(finished_env[:body])
|
11
12
|
end
|
12
13
|
end
|
13
|
-
rescue LoadError => e
|
14
|
+
rescue LoadError, NameError => e
|
14
15
|
self.load_error = e
|
15
16
|
end
|
16
17
|
|
@@ -5,10 +5,10 @@ class ResponseMiddlewareTest < Faraday::TestCase
|
|
5
5
|
[:yajl, :rails_json].each do |key|
|
6
6
|
parser = Faraday::Response.lookup_module(key)
|
7
7
|
next if !parser.loaded?
|
8
|
-
it "uses #{parser}" do
|
8
|
+
it "uses #{parser} to parse json content" do
|
9
9
|
@connection = Faraday::Connection.new do |b|
|
10
10
|
b.adapter :test do |stub|
|
11
|
-
stub.get('json')
|
11
|
+
stub.get('json') { [200, {'Content-Type' => 'text/html'}, "[1,2,3]"] }
|
12
12
|
end
|
13
13
|
b.use parser
|
14
14
|
end
|
@@ -16,6 +16,30 @@ class ResponseMiddlewareTest < Faraday::TestCase
|
|
16
16
|
assert response.success?
|
17
17
|
assert_equal [1,2,3], response.body
|
18
18
|
end
|
19
|
+
|
20
|
+
it "uses #{parser} to skip blank content" do
|
21
|
+
@connection = Faraday::Connection.new do |b|
|
22
|
+
b.adapter :test do |stub|
|
23
|
+
stub.get('blank') { [200, {'Content-Type' => 'text/html'}, ''] }
|
24
|
+
end
|
25
|
+
b.use parser
|
26
|
+
end
|
27
|
+
response = @connection.get('blank')
|
28
|
+
assert response.success?
|
29
|
+
assert_equal nil, response.body
|
30
|
+
end
|
31
|
+
|
32
|
+
it "uses #{parser} to skip nil content" do
|
33
|
+
@connection = Faraday::Connection.new do |b|
|
34
|
+
b.adapter :test do |stub|
|
35
|
+
stub.get('nil') { [200, {'Content-Type' => 'text/html'}, nil] }
|
36
|
+
end
|
37
|
+
b.use parser
|
38
|
+
end
|
39
|
+
response = @connection.get('nil')
|
40
|
+
assert response.success?
|
41
|
+
assert_equal nil, response.body
|
42
|
+
end
|
19
43
|
end
|
20
44
|
end
|
21
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rick
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-06 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|