faraday 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
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 Rakefile, and run the gemspec command
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.1"
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-04}
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 = [
@@ -3,7 +3,7 @@ module Faraday
3
3
  class Patron < Middleware
4
4
  begin
5
5
  require 'patron'
6
- rescue LoadError => e
6
+ rescue LoadError, NameError => e
7
7
  self.load_error = e
8
8
  end
9
9
 
@@ -9,7 +9,7 @@ module Faraday
9
9
 
10
10
  begin
11
11
  require 'typhoeus'
12
- rescue LoadError => e
12
+ rescue LoadError, NameError => e
13
13
  self.load_error = e
14
14
  end
15
15
 
@@ -3,9 +3,10 @@ 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
- rescue LoadError => e
9
+ rescue LoadError, NameError => e
9
10
  self.load_error = e
10
11
  end
11
12
 
@@ -3,7 +3,7 @@ module Faraday
3
3
  begin
4
4
  require 'yajl'
5
5
 
6
- rescue LoadError => e
6
+ rescue LoadError, NameError => e
7
7
  self.load_error = e
8
8
  end
9
9
 
@@ -41,6 +41,7 @@ module Faraday
41
41
  end
42
42
 
43
43
  def finish(env)
44
+ env[:body] ||= ''
44
45
  @on_complete_callbacks.each { |c| c.call(env) }
45
46
  @status, @headers, @body = env[:status], env[:response_headers], env[:body]
46
47
  self
@@ -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
 
@@ -8,7 +8,7 @@ module Faraday
8
8
  finished_env[:body] = Yajl::Parser.parse(finished_env[:body])
9
9
  end
10
10
  end
11
- rescue LoadError => e
11
+ rescue LoadError, NameError => e
12
12
  self.load_error = e
13
13
  end
14
14
 
@@ -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') { [200, {'Content-Type' => 'text/html'}, "[1,2,3]"] }
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.1
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-04 00:00:00 -08:00
12
+ date: 2010-02-06 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency