spec/mongrel2/httpresponse_spec.rb in mongrel2-0.24.0 vs spec/mongrel2/httpresponse_spec.rb in mongrel2-0.25.0.pre.285

- old
+ new

@@ -73,11 +73,11 @@ @response << "More data!" @response.header_data.should =~ /Content-length: 10/i end it "doesn't have a body" do - @response.body.should be_empty() + @response.body.size.should == 0 end it "stringifies to a valid RFC2616 response string" do @response.to_s.should =~ HTTP_RESPONSE end @@ -92,11 +92,12 @@ @response.status = HTTP::OK @response.reset @response.should_not be_handled() - @response.body.should == '' + @response.body.should be_a( StringIO ) + @response.body.size.should == 0 @response.headers.should have(1).keys end it "sets its status line to 200 OK if the body is set and the status hasn't yet been set" do @response << "Some stuff" @@ -114,11 +115,11 @@ @response.get_content_length.should == test_body.length end it "can find the length of its body if it's a String with multi-byte characters in it" do test_body = 'Хорошая собака, Стрелке! Очень хорошо.' - @response.body = test_body + @response << test_body @response.get_content_length.should == test_body.bytesize end it "can find the length of its body if it's a seekable IO" do @@ -236,19 +237,11 @@ it "returns a body length of 0 if it's a bodiless reponse" do @response.status = HTTP::NO_CONTENT @response.get_content_length.should == 0 end - it "raises a descriptive error message if it can't get the body's length" do - @response.body = Object.new - lambda { - @response.get_content_length - }.should raise_error( Mongrel2::ResponseError, /content length/i ) - end - - it "can build a valid HTTP status line for its status" do @response.status = HTTP::SEE_OTHER @response.status_line.should == "HTTP/1.1 303 See Other" end @@ -269,10 +262,11 @@ @response.should be_keepalive() end it "has a puts method for appending objects to the body" do @response.puts( :something_to_sable ) - @response.body.should == "something_to_sable\n" + @response.body.rewind + @response.body.read.should == "something_to_sable\n" end end