public
Rubygem
Description: Makes http fun! Also, makes consuming restful web services dead easy.
Homepage:
Clone URL: git://github.com/jnunemaker/httparty.git
Click here to lend your support to: httparty and make a donation at www.pledgie.com !
Added a spec for the missing mimetype. Honestly don't think it is properly 
testing it. Someone is free to show me the way.
jnunemaker (author)
Tue Dec 23 10:09:45 -0800 2008
commit  282ae78648bbe3673eef4345ebb36e26d39de495
tree    459613b331d4ab58d78af1e6d3d41bf56e8ed2d9
parent  80bfce407caba62051bc798d7d1d5d66aa531407
...
106
107
108
109
 
110
111
112
...
106
107
108
 
109
110
111
112
0
@@ -106,7 +106,7 @@ module HTTParty
0
       # Uses the HTTP Content-Type header to determine the format of the response
0
       # It compares the MIME type returned to the types stored in the AllowedFormats hash
0
       def format_from_mimetype(mimetype) #:nodoc:
0
-        return nil unless mimetype
0
+        return nil if mimetype.nil?
0
         AllowedFormats.each { |k, v| return k if mimetype.include?(v) }
0
       end
0
       
...
48
49
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
52
53
...
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
0
@@ -48,6 +48,20 @@ describe HTTParty::Request do
0
     response.stub!(:body).and_return("")
0
     @request.perform.should be_nil
0
   end
0
+  
0
+  it "should not fail for missing mime type" do
0
+    http = Net::HTTP.new('localhost', 80)
0
+    @request.stub!(:http).and_return(http)
0
+    
0
+    response = Net::HTTPOK.new("1.1", 200, "Content for you")
0
+    response.stub!(:[]).with('content-type').and_return(nil)
0
+    response.stub!(:body).and_return('Content for you')
0
+    
0
+    http.stub!(:request).and_return(response)
0
+    
0
+    @request.options[:format] = :html
0
+    @request.perform.should == 'Content for you'
0
+  end
0
 
0
   describe "that respond with redirects" do
0
     def setup_redirect

Comments