spec/http2_spec.rb in http2-0.0.24 vs spec/http2_spec.rb in http2-0.0.25

- old
+ new

@@ -1,29 +1,8 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Http2" do - it "should be able to recursively parse post-data-hashes." do - res = Http2.post_convert_data( - "test1" => "test2" - ) - raise "Expected 'test1=test2' but got: '#{res}'." if res != "test1=test2" - - res = Http2.post_convert_data( - "test1" => [1, 2, 3] - ) - raise "Expected 'test1%5B0%5D=1&test1%5B1%5D=2&test1%5B2%5D=3' but got: '#{res}'." if res != "test1%5B0%5D=1&test1%5B1%5D=2&test1%5B2%5D=3" - - res = Http2.post_convert_data( - "test1" => { - "order" => { - [:Bnet_profile, "profile_id"] => 5 - } - } - ) - raise "Expected 'test1%5Border%5D%5B%5B%3ABnet_profile%2C+%22profile_id%22%5D%5D=5' but got: '#{res}'." if res != "test1%5Border%5D%5B%5B%3ABnet_profile%2C+%22profile_id%22%5D%5D=5" - end - it "should be able to do normal post-requests." do require "json" #Test posting keep-alive and advanced post-data. Http2.new(:host => "www.partyworm.dk", :debug => false) do |http| @@ -136,16 +115,31 @@ it "should be able to post custom content types" do require "json" Http2.new(:host => "http2test.kaspernj.org") do |http| res = http.post( - :url => "/content_type_test.php", - :content_type => "plain/text", - :post => "test1_test2_test3" + url: "content_type_test.php", + content_type: "plain/text", + post: "test1_test2_test3" ) data = JSON.parse(res.body) data["_SERVER"]["CONTENT_TYPE"].should eql("plain/text") data["PHP_INPUT"].should eql("test1_test2_test3") + end + end + + it "should set various timeouts" do + Http2.new(:host => "http2test.kaspernj.org") do |http| + res = http.get("content_type_test.php") + http.keepalive_timeout.should eq 5 + http.keepalive_max.should eq 100 + end + end + + it "should follow redirects" do + Http2.new(host: "http2test.kaspernj.org", follow_redirects: true) do |http| + resp = http.get("redirect_test.php") + resp.code.should eq "200" end end end \ No newline at end of file