diff options
Diffstat (limited to 'spec/ruby/library/net-http/httpgenericrequest')
7 files changed, 44 insertions, 40 deletions
diff --git a/spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb index 6c886499ca..96a761929e 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb @@ -4,10 +4,10 @@ require 'net/http' describe "Net::HTTPGenericRequest#body_exist?" do it "returns true when the response is expected to have a body" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body_exist?.should be_true + request.body_exist?.should == true request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path") - request.body_exist?.should be_false + request.body_exist?.should == false end describe "when $VERBOSE is true" do diff --git a/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb index 5f7315f303..63cda994e5 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb @@ -5,7 +5,7 @@ require "stringio" describe "Net::HTTPGenericRequest#body" do it "returns self's request body" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body.should be_nil + request.body.should == nil request.body = "Some Content" request.body.should == "Some Content" @@ -25,6 +25,6 @@ describe "Net::HTTPGenericRequest#body=" do it "sets self's body stream to nil" do @request.body_stream = StringIO.new("") @request.body = "Some Content" - @request.body_stream.should be_nil + @request.body_stream.should == nil end end diff --git a/spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb index dea1c8c883..3237dbb861 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb @@ -5,11 +5,11 @@ require "stringio" describe "Net::HTTPGenericRequest#body_stream" do it "returns self's body stream Object" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body_stream.should be_nil + request.body_stream.should == nil stream = StringIO.new("test") request.body_stream = stream - request.body_stream.should equal(stream) + request.body_stream.should.equal?(stream) end end @@ -21,12 +21,12 @@ describe "Net::HTTPGenericRequest#body_stream=" do it "sets self's body stream to the passed Object" do @request.body_stream = @stream - @request.body_stream.should equal(@stream) + @request.body_stream.should.equal?(@stream) end it "sets self's body to nil" do @request.body = "Some Content" @request.body_stream = @stream - @request.body.should be_nil + @request.body.should == nil end end diff --git a/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb index 7de03d7da0..0ccf80e3b6 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb @@ -31,18 +31,20 @@ describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do end describe "when a request body is set" do - it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body = "Some Content" - - request.exec(@buffered_socket, "1.1", "/some/other/path") - str = @socket.string - - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] - str.should =~ %r[Content-Length: 12\r\n] - str[-16..-1].should == "\r\n\r\nSome Content" + ruby_version_is ""..."4.0" do + it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do + request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") + request.body = "Some Content" + + request.exec(@buffered_socket, "1.1", "/some/other/path") + str = @socket.string + + str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] + str.should =~ %r[Accept: \*/\*\r\n] + str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] + str.should =~ %r[Content-Length: 12\r\n] + str[-16..-1].should == "\r\n\r\nSome Content" + end end it "correctly sets the 'Content-Length' header and includes the body" do @@ -62,19 +64,21 @@ describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do end describe "when a body stream is set" do - it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path", - "Content-Length" => "10") - request.body_stream = StringIO.new("a" * 20) - - request.exec(@buffered_socket, "1.1", "/some/other/path") - str = @socket.string - - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] - str.should =~ %r[Content-Length: 10\r\n] - str[-24..-1].should == "\r\n\r\naaaaaaaaaaaaaaaaaaaa" + ruby_version_is ""..."4.0" do + it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do + request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path", + "Content-Length" => "10") + request.body_stream = StringIO.new("a" * 20) + + request.exec(@buffered_socket, "1.1", "/some/other/path") + str = @socket.string + + str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] + str.should =~ %r[Accept: \*/\*\r\n] + str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] + str.should =~ %r[Content-Length: 10\r\n] + str[-24..-1].should == "\r\n\r\naaaaaaaaaaaaaaaaaaaa" + end end it "sends the whole stream, regardless of the 'Content-Length' header" do @@ -125,7 +129,7 @@ describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do "Content-Type" => "text/html") request.body_stream = StringIO.new("Some Content") - -> { request.exec(@buffered_socket, "1.1", "/some/other/path") }.should raise_error(ArgumentError) + -> { request.exec(@buffered_socket, "1.1", "/some/other/path") }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/library/net-http/httpgenericrequest/request_body_permitted_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/request_body_permitted_spec.rb index 1713b59baf..ba836e8130 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/request_body_permitted_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/request_body_permitted_spec.rb @@ -4,9 +4,9 @@ require 'net/http' describe "Net::HTTPGenericRequest#request_body_permitted?" do it "returns true when the request is expected to have a body" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.request_body_permitted?.should be_true + request.request_body_permitted?.should == true request = Net::HTTPGenericRequest.new("POST", false, true, "/some/path") - request.request_body_permitted?.should be_false + request.request_body_permitted?.should == false end end diff --git a/spec/ruby/library/net-http/httpgenericrequest/response_body_permitted_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/response_body_permitted_spec.rb index 2f0751c344..067500f60d 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/response_body_permitted_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/response_body_permitted_spec.rb @@ -4,9 +4,9 @@ require 'net/http' describe "Net::HTTPGenericRequest#response_body_permitted?" do it "returns true when the response is expected to have a body" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.response_body_permitted?.should be_true + request.response_body_permitted?.should == true request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path") - request.response_body_permitted?.should be_false + request.response_body_permitted?.should == false end end diff --git a/spec/ruby/library/net-http/httpgenericrequest/set_body_internal_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/set_body_internal_spec.rb index 358aa6cde3..f241d8d698 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/set_body_internal_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/set_body_internal_spec.rb @@ -13,9 +13,9 @@ describe "Net::HTTPGenericRequest#set_body_internal when passed string" do it "raises an ArgumentError when the body or body_stream of self have already been set" do @request.body = "Some Content" - -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) + -> { @request.set_body_internal("Some other Content") }.should.raise(ArgumentError) @request.body_stream = "Some Content" - -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) + -> { @request.set_body_internal("Some other Content") }.should.raise(ArgumentError) end end |
