Skip to content

Commit

Permalink
Make response honor respond to
Browse files Browse the repository at this point in the history
  • Loading branch information
mmangino committed Mar 2, 2011
1 parent 00a7ec9 commit b18c48f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
httparty (0.7.2)
httparty (0.7.4)
crack (= 0.1.8)

GEM
Expand Down
5 changes: 5 additions & 0 deletions lib/httparty/response.rb
Expand Up @@ -64,6 +64,11 @@ def inspect
klass === response
end
end

def respond_to?(name)
return true if [:request,:response,:parsed_response,:body,:headers].include?(name)
parsed_response.respond_to?(name) or response.respond_to?(name)
end

protected

Expand Down
5 changes: 5 additions & 0 deletions spec/httparty/response_spec.rb
Expand Up @@ -54,6 +54,11 @@
response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'})
response['foo'].should == 'bar'
end

it "should respond_to? methods it supports" do
response = HTTParty::Response.new(@request_object, @response_object, {'foo' => 'bar'})
response.respond_to?(:parsed_response).should be_true
end

it "should be able to iterate if it is array" do
response = HTTParty::Response.new(@request_object, @response_object, [{'foo' => 'bar'}, {'foo' => 'baz'}])
Expand Down

0 comments on commit b18c48f

Please sign in to comment.