Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

faraday 0.8 must have changed the way they handle urls

had a bunch of failing tests due to unescaped uris
  • Loading branch information...
commit 9f466a737c8651857d4e5abb0f91935972c11d68 1 parent fd41b65
Ryan Rauh authored May 05, 2012
2  ghee.gemspec
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24 24
   s.add_runtime_dependency 'yajl-ruby'
25 25
   s.add_development_dependency 'rake'
26 26
   s.add_development_dependency 'json_pure'
27  
-  s.add_development_dependency 'rspec', '~>2.0'
  27
+  s.add_development_dependency 'rspec', '~>2.9.0'
28 28
   s.add_development_dependency 'webmock'
29 29
   s.add_development_dependency 'vcr'
30 30
   s.add_development_dependency 'ZenTest'
1  lib/ghee.rb
... ...
@@ -1,6 +1,7 @@
1 1
 # encoding: UTF-8
2 2
 require 'ghee/version'
3 3
 require 'ghee/connection'
  4
+require 'ghee/uri_escape'
4 5
 require 'ghee/resource_proxy'
5 6
 require 'ghee/state_methods'
6 7
 require 'ghee/api/authorizations'
1  lib/ghee/connection.rb
@@ -22,6 +22,7 @@ def initialize(hash={})
22 22
       super('https://api.github.com') do |builder|
23 23
         builder.use     FaradayMiddleware::EncodeJson
24 24
         builder.use     FaradayMiddleware::ParseJson
  25
+      #  builder.use     Ghee::Middleware::UriEscape
25 26
         builder.adapter Faraday.default_adapter
26 27
       end
27 28
 
6  lib/ghee/state_methods.rb
@@ -6,7 +6,7 @@ module CUD
6 6
     # return json
7 7
     #
8 8
     def create(attributes)
9  
-      connection.post(path_prefix,attributes).body
  9
+      connection.post(URI.escape(path_prefix),attributes).body
10 10
     end
11 11
 
12 12
     # Patchs 
@@ -14,7 +14,7 @@ def create(attributes)
14 14
     # return json
15 15
     #
16 16
     def patch(attributes)
17  
-      connection.patch(path_prefix, attributes).body
  17
+      connection.patch(URI.escape(path_prefix), attributes).body
18 18
     end
19 19
 
20 20
     # Destroys 
@@ -22,7 +22,7 @@ def patch(attributes)
22 22
     # return boolean
23 23
     #
24 24
     def destroy
25  
-      connection.delete(path_prefix).status == 204
  25
+      connection.delete(URI.escape(path_prefix)).status == 204
26 26
     end
27 27
   end
28 28
 
11  lib/ghee/uri_escape.rb
... ...
@@ -0,0 +1,11 @@
  1
+class Ghee
  2
+  module Middleware
  3
+    class UriEscape < Faraday::Middleware
  4
+      def call(env)
  5
+
  6
+        env[:url] = URI.parse(URI.escape(env[:url].to_s))
  7
+        @app.call(env)
  8
+      end
  9
+    end
  10
+  end
  11
+end
1  spec/ghee/api/events_spec.rb
@@ -12,7 +12,6 @@ def should_be_an_event(event)
12 12
     EventTypes.should include(event['type'])
13 13
     event['repo'].should be_instance_of(Hash)
14 14
     event['actor'].should be_instance_of(Hash)
15  
-    event['org'].should be_instance_of(Hash)
16 15
     event['created_at'].should_not be_nil
17 16
   end
18 17
 

0 notes on commit 9f466a7

Please sign in to comment.
Something went wrong with that request. Please try again.