Permalink
Browse files

faraday 0.8 must have changed the way they handle urls

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

0 comments on commit 9f466a7

Please sign in to comment.