Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fixing error when content-type has charset #2

Merged
merged 1 commit into from

2 participants

@nadilsons

No description provided.

@rogerleite rogerleite merged commit f1d0c5f into rogerleite:master
@rogerleite
Owner

Nadilson, valeu pelo pull request!
Ainda não testei nas APIs do Alexandria. Mas a idéia é esta mesmo, deu pau é só contribuir!

@nadilsons

Estou tentando utilizar esta gem em um projeto e vi este erro pq mockei as interacoes com a api com o vcr :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 20, 2012
  1. fix error when content-type has charset

    Nadilson authored
This page is out of date. Refresh to see the latest.
View
2  lib/restfolia/http_behaviour.rb
@@ -40,7 +40,7 @@ def response_by_status_code(http_response)
# "aplication/json".
def on_2xx(http_response)
- content_type = (http_response["content-type"] == "application/json")
+ content_type = (http_response["content-type"] =~ /application\/json/)
if !content_type
msg_error = "Response \"content-type\" header should be \"application/json\""
raise(ResponseError, msg_error, caller)
View
8 test/restfolia/http_behaviour_test.rb
@@ -46,6 +46,14 @@
value.must_be_instance_of(Restfolia::Resource)
end
+ it "should return Resource for HTTP Response when content-type is 'application/json; charset=utf-8'" do
+ @http_mock.expect(:[], "application/json; charset=utf-8", ["content-type"])
+ @http_mock.expect(:body, '{"attr_test": "test"}')
+
+ value = Restfolia::HTTPBehaviour.on_2xx(@http_mock)
+ value.must_be_instance_of(Restfolia::Resource)
+ end
+
it "should return Resource for HTTP Response with Location header" do
@http_mock.expect(:code, "201")
@http_mock.expect(:body, nil)
Something went wrong with that request. Please try again.