diff options
Diffstat (limited to 'spec/ruby/library/net-http')
114 files changed, 759 insertions, 799 deletions
diff --git a/spec/ruby/library/net-http/HTTPServerException_spec.rb b/spec/ruby/library/net-http/HTTPServerException_spec.rb index 5e0a833fee..020d3cce85 100644 --- a/spec/ruby/library/net-http/HTTPServerException_spec.rb +++ b/spec/ruby/library/net-http/HTTPServerException_spec.rb @@ -3,10 +3,10 @@ require 'net/http' describe "Net::HTTPServerException" do it "is a subclass of Net::ProtoServerError and is warned as deprecated" do - -> { Net::HTTPServerException.should < Net::ProtoServerError }.should complain(/warning: constant Net::HTTPServerException is deprecated/) + -> { eval("Net::HTTPServerException").should < Net::ProtoServerError }.should complain(/warning: constant Net::HTTPServerException is deprecated/) end it "includes the Net::HTTPExceptions module and is warned as deprecated" do - -> { Net::HTTPServerException.should < Net::HTTPExceptions }.should complain(/warning: constant Net::HTTPServerException is deprecated/) + -> { eval("Net::HTTPServerException").should < Net::HTTPExceptions }.should complain(/warning: constant Net::HTTPServerException is deprecated/) end end diff --git a/spec/ruby/library/net-http/http/Proxy_spec.rb b/spec/ruby/library/net-http/http/Proxy_spec.rb index a1a04fa00b..7753ce5e30 100644 --- a/spec/ruby/library/net-http/http/Proxy_spec.rb +++ b/spec/ruby/library/net-http/http/Proxy_spec.rb @@ -13,7 +13,7 @@ describe "Net::HTTP.Proxy" do it "sets the returned subclasses' proxy options based on the passed arguments" do http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") http_with_proxy.proxy_address.should == "localhost" - http_with_proxy.proxy_port.should eql(1234) + http_with_proxy.proxy_port.should.eql?(1234) http_with_proxy.proxy_user.should == "rspec" http_with_proxy.proxy_pass.should == "rocks" end @@ -22,14 +22,14 @@ end describe "Net::HTTP#proxy?" do describe "when self is no proxy class instance" do it "returns false" do - Net::HTTP.new("localhost", 3333).proxy?.should be_false + Net::HTTP.new("localhost", 3333).proxy?.should == false end end describe "when self is a proxy class instance" do it "returns false" do http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy?.should be_true + http_with_proxy.new("localhost", 3333).proxy?.should == true end end end diff --git a/spec/ruby/library/net-http/http/active_spec.rb b/spec/ruby/library/net-http/http/active_spec.rb index c260274594..ba870b39d2 100644 --- a/spec/ruby/library/net-http/http/active_spec.rb +++ b/spec/ruby/library/net-http/http/active_spec.rb @@ -1,8 +1,8 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/started' describe "Net::HTTP#active?" do - it_behaves_like :net_http_started_p, :active? + it "is an alias of Net::HTTP#started?" do + Net::HTTP.instance_method(:active?).should == Net::HTTP.instance_method(:started?) + end end diff --git a/spec/ruby/library/net-http/http/copy_spec.rb b/spec/ruby/library/net-http/http/copy_spec.rb index fba96c0f11..1f3e25009f 100644 --- a/spec/ruby/library/net-http/http/copy_spec.rb +++ b/spec/ruby/library/net-http/http/copy_spec.rb @@ -15,7 +15,7 @@ describe "Net::HTTP#copy" do it "sends a COPY request to the passed path and returns the response" do response = @http.copy("/request") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) response.body.should == "Request type: COPY" end end diff --git a/spec/ruby/library/net-http/http/default_port_spec.rb b/spec/ruby/library/net-http/http/default_port_spec.rb index 95b7316a0c..20407d0b12 100644 --- a/spec/ruby/library/net-http/http/default_port_spec.rb +++ b/spec/ruby/library/net-http/http/default_port_spec.rb @@ -3,6 +3,6 @@ require 'net/http' describe "Net::HTTP.default_port" do it "returns 80" do - Net::HTTP.http_default_port.should eql(80) + Net::HTTP.http_default_port.should.eql?(80) end end diff --git a/spec/ruby/library/net-http/http/delete_spec.rb b/spec/ruby/library/net-http/http/delete_spec.rb index d73aa5b375..09ddd74000 100644 --- a/spec/ruby/library/net-http/http/delete_spec.rb +++ b/spec/ruby/library/net-http/http/delete_spec.rb @@ -15,7 +15,7 @@ describe "Net::HTTP#delete" do it "sends a DELETE request to the passed path and returns the response" do response = @http.delete("/request") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) response.body.should == "Request type: DELETE" end end diff --git a/spec/ruby/library/net-http/http/finish_spec.rb b/spec/ruby/library/net-http/http/finish_spec.rb index d4aa00dffe..0d466675f3 100644 --- a/spec/ruby/library/net-http/http/finish_spec.rb +++ b/spec/ruby/library/net-http/http/finish_spec.rb @@ -17,13 +17,13 @@ describe "Net::HTTP#finish" do it "closes the tcp connection" do @http.start @http.finish - @http.started?.should be_false + @http.started?.should == false end end describe "when self has not been started yet" do it "raises an IOError" do - -> { @http.finish }.should raise_error(IOError) + -> { @http.finish }.should.raise(IOError) end end end diff --git a/spec/ruby/library/net-http/http/get2_spec.rb b/spec/ruby/library/net-http/http/get2_spec.rb index 57c05ec64b..046443d73e 100644 --- a/spec/ruby/library/net-http/http/get2_spec.rb +++ b/spec/ruby/library/net-http/http/get2_spec.rb @@ -1,8 +1,8 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_get' describe "Net::HTTP#get2" do - it_behaves_like :net_http_request_get, :get2 + it "is an alias of Net::HTTP#request_get" do + Net::HTTP.instance_method(:get2).should == Net::HTTP.instance_method(:request_get) + end end diff --git a/spec/ruby/library/net-http/http/get_spec.rb b/spec/ruby/library/net-http/http/get_spec.rb index e64a61c52c..9be726dc3b 100644 --- a/spec/ruby/library/net-http/http/get_spec.rb +++ b/spec/ruby/library/net-http/http/get_spec.rb @@ -74,7 +74,7 @@ describe "Net::HTTP.get" do socket, client_thread = start_threads begin client_thread.raise my_exception, "my exception" - -> { client_thread.value }.should raise_error(my_exception) + -> { client_thread.value }.should.raise(my_exception) ensure socket.close end diff --git a/spec/ruby/library/net-http/http/head2_spec.rb b/spec/ruby/library/net-http/http/head2_spec.rb index 84cfff33d7..19c0cede9f 100644 --- a/spec/ruby/library/net-http/http/head2_spec.rb +++ b/spec/ruby/library/net-http/http/head2_spec.rb @@ -1,8 +1,8 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_head' describe "Net::HTTP#head2" do - it_behaves_like :net_http_request_head, :head2 + it "is an alias of Net::HTTP#request_head" do + Net::HTTP.instance_method(:head2).should == Net::HTTP.instance_method(:request_head) + end end diff --git a/spec/ruby/library/net-http/http/head_spec.rb b/spec/ruby/library/net-http/http/head_spec.rb index 64621fa87b..4824d22534 100644 --- a/spec/ruby/library/net-http/http/head_spec.rb +++ b/spec/ruby/library/net-http/http/head_spec.rb @@ -16,10 +16,10 @@ describe "Net::HTTP#head" do it "sends a HEAD request to the passed path and returns the response" do response = @http.head("/request") # HEAD requests have no responses - response.body.should be_nil + response.body.should == nil end it "returns a Net::HTTPResponse" do - @http.head("/request").should be_kind_of(Net::HTTPResponse) + @http.head("/request").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/http_default_port_spec.rb b/spec/ruby/library/net-http/http/http_default_port_spec.rb index 3b17bcd0a5..82c88e58a8 100644 --- a/spec/ruby/library/net-http/http/http_default_port_spec.rb +++ b/spec/ruby/library/net-http/http/http_default_port_spec.rb @@ -3,6 +3,6 @@ require 'net/http' describe "Net::HTTP.http_default_port" do it "returns 80" do - Net::HTTP.http_default_port.should eql(80) + Net::HTTP.http_default_port.should.eql?(80) end end diff --git a/spec/ruby/library/net-http/http/https_default_port_spec.rb b/spec/ruby/library/net-http/http/https_default_port_spec.rb index 8c24e1d97c..24b9c3b462 100644 --- a/spec/ruby/library/net-http/http/https_default_port_spec.rb +++ b/spec/ruby/library/net-http/http/https_default_port_spec.rb @@ -3,6 +3,6 @@ require 'net/http' describe "Net::HTTP.https_default_port" do it "returns 443" do - Net::HTTP.https_default_port.should eql(443) + Net::HTTP.https_default_port.should.eql?(443) end end diff --git a/spec/ruby/library/net-http/http/initialize_spec.rb b/spec/ruby/library/net-http/http/initialize_spec.rb index 78aa01e1aa..907314cb25 100644 --- a/spec/ruby/library/net-http/http/initialize_spec.rb +++ b/spec/ruby/library/net-http/http/initialize_spec.rb @@ -3,7 +3,7 @@ require 'net/http' describe "Net::HTTP#initialize" do it "is private" do - Net::HTTP.should have_private_instance_method(:initialize) + Net::HTTP.private_instance_methods(false).should.include?(:initialize) end describe "when passed address" do @@ -17,11 +17,11 @@ describe "Net::HTTP#initialize" do end it "sets the new Net::HTTP instance's port to the default HTTP port" do - @net.port.should eql(Net::HTTP.default_port) + @net.port.should.eql?(Net::HTTP.default_port) end it "does not start the new Net::HTTP instance" do - @net.started?.should be_false + @net.started?.should == false end end @@ -36,11 +36,11 @@ describe "Net::HTTP#initialize" do end it "sets the new Net::HTTP instance's port to the passed port" do - @net.port.should eql(3333) + @net.port.should.eql?(3333) end it "does not start the new Net::HTTP instance" do - @net.started?.should be_false + @net.started?.should == false end end end diff --git a/spec/ruby/library/net-http/http/inspect_spec.rb b/spec/ruby/library/net-http/http/inspect_spec.rb index b8f650809e..fd4e6116c7 100644 --- a/spec/ruby/library/net-http/http/inspect_spec.rb +++ b/spec/ruby/library/net-http/http/inspect_spec.rb @@ -15,7 +15,7 @@ describe "Net::HTTP#inspect" do end it "returns a String representation of self" do - @http.inspect.should be_kind_of(String) + @http.inspect.should.is_a?(String) @http.inspect.should == "#<Net::HTTP localhost:#{@port} open=false>" @http.start diff --git a/spec/ruby/library/net-http/http/is_version_1_1_spec.rb b/spec/ruby/library/net-http/http/is_version_1_1_spec.rb index bdb343f9e0..f4910ef1e4 100644 --- a/spec/ruby/library/net-http/http/is_version_1_1_spec.rb +++ b/spec/ruby/library/net-http/http/is_version_1_1_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'shared/version_1_1' describe "Net::HTTP.is_version_1_1?" do - it_behaves_like :net_http_version_1_1_p, :is_version_1_1? + it "is an alias of Net::HTTP.version_1_1?" do + Net::HTTP.method(:is_version_1_1?).should == Net::HTTP.method(:version_1_1?) + end end diff --git a/spec/ruby/library/net-http/http/is_version_1_2_spec.rb b/spec/ruby/library/net-http/http/is_version_1_2_spec.rb index 555bb205dd..555724babe 100644 --- a/spec/ruby/library/net-http/http/is_version_1_2_spec.rb +++ b/spec/ruby/library/net-http/http/is_version_1_2_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'shared/version_1_2' describe "Net::HTTP.is_version_1_2?" do - it_behaves_like :net_http_version_1_2_p, :is_version_1_2? + it "is an alias of Net::HTTP.version_1_2?" do + Net::HTTP.method(:is_version_1_2?).should == Net::HTTP.method(:version_1_2?) + end end diff --git a/spec/ruby/library/net-http/http/lock_spec.rb b/spec/ruby/library/net-http/http/lock_spec.rb index aa1f944196..12df138ad0 100644 --- a/spec/ruby/library/net-http/http/lock_spec.rb +++ b/spec/ruby/library/net-http/http/lock_spec.rb @@ -15,7 +15,7 @@ describe "Net::HTTP#lock" do it "sends a LOCK request to the passed path and returns the response" do response = @http.lock("/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) response.body.should == "Request type: LOCK" end end diff --git a/spec/ruby/library/net-http/http/mkcol_spec.rb b/spec/ruby/library/net-http/http/mkcol_spec.rb index f8009f9059..b1a5055982 100644 --- a/spec/ruby/library/net-http/http/mkcol_spec.rb +++ b/spec/ruby/library/net-http/http/mkcol_spec.rb @@ -15,7 +15,7 @@ describe "Net::HTTP#mkcol" do it "sends a MKCOL request to the passed path and returns the response" do response = @http.mkcol("/request") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) response.body.should == "Request type: MKCOL" end end diff --git a/spec/ruby/library/net-http/http/move_spec.rb b/spec/ruby/library/net-http/http/move_spec.rb index ae43016a2c..a57c2a0f49 100644 --- a/spec/ruby/library/net-http/http/move_spec.rb +++ b/spec/ruby/library/net-http/http/move_spec.rb @@ -20,6 +20,6 @@ describe "Net::HTTP#head" do end it "returns a Net::HTTPResponse" do - @http.move("/request").should be_kind_of(Net::HTTPResponse) + @http.move("/request").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/new_spec.rb b/spec/ruby/library/net-http/http/new_spec.rb index 1ec6bbd0c0..8feb3d1351 100644 --- a/spec/ruby/library/net-http/http/new_spec.rb +++ b/spec/ruby/library/net-http/http/new_spec.rb @@ -8,8 +8,8 @@ describe "Net::HTTP.new" do end it "returns a Net::HTTP instance" do - @http.proxy?.should be_false - @http.instance_of?(Net::HTTP).should be_true + @http.proxy?.should == false + @http.instance_of?(Net::HTTP).should == true end it "sets the new Net::HTTP instance's address to the passed address" do @@ -17,11 +17,11 @@ describe "Net::HTTP.new" do end it "sets the new Net::HTTP instance's port to the default HTTP port" do - @http.port.should eql(Net::HTTP.default_port) + @http.port.should.eql?(Net::HTTP.default_port) end it "does not start the new Net::HTTP instance" do - @http.started?.should be_false + @http.started?.should == false end end @@ -31,8 +31,8 @@ describe "Net::HTTP.new" do end it "returns a Net::HTTP instance" do - @http.proxy?.should be_false - @http.instance_of?(Net::HTTP).should be_true + @http.proxy?.should == false + @http.instance_of?(Net::HTTP).should == true end it "sets the new Net::HTTP instance's address to the passed address" do @@ -40,44 +40,44 @@ describe "Net::HTTP.new" do end it "sets the new Net::HTTP instance's port to the passed port" do - @http.port.should eql(3333) + @http.port.should.eql?(3333) end it "does not start the new Net::HTTP instance" do - @http.started?.should be_false + @http.started?.should == false end end describe "when passed address, port, *proxy_options" do it "returns a Net::HTTP instance" do http = Net::HTTP.new("localhost", 3333, "localhost") - http.proxy?.should be_true - http.instance_of?(Net::HTTP).should be_true - http.should be_kind_of(Net::HTTP) + http.proxy?.should == true + http.instance_of?(Net::HTTP).should == true + http.should.is_a?(Net::HTTP) end it "correctly sets the passed Proxy options" do http = Net::HTTP.new("localhost", 3333, "localhost") http.proxy_address.should == "localhost" - http.proxy_port.should eql(80) - http.proxy_user.should be_nil - http.proxy_pass.should be_nil + http.proxy_port.should.eql?(80) + http.proxy_user.should == nil + http.proxy_pass.should == nil http = Net::HTTP.new("localhost", 3333, "localhost", 1234) http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) - http.proxy_user.should be_nil - http.proxy_pass.should be_nil + http.proxy_port.should.eql?(1234) + http.proxy_user.should == nil + http.proxy_pass.should == nil http = Net::HTTP.new("localhost", 3333, "localhost", 1234, "rubyspec") http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) + http.proxy_port.should.eql?(1234) http.proxy_user.should == "rubyspec" - http.proxy_pass.should be_nil + http.proxy_pass.should == nil http = Net::HTTP.new("localhost", 3333, "localhost", 1234, "rubyspec", "rocks") http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) + http.proxy_port.should.eql?(1234) http.proxy_user.should == "rubyspec" http.proxy_pass.should == "rocks" end diff --git a/spec/ruby/library/net-http/http/newobj_spec.rb b/spec/ruby/library/net-http/http/newobj_spec.rb index e19b30fca9..d398fb7d9a 100644 --- a/spec/ruby/library/net-http/http/newobj_spec.rb +++ b/spec/ruby/library/net-http/http/newobj_spec.rb @@ -8,7 +8,7 @@ describe "Net::HTTP.newobj" do describe "when passed address" do it "returns a new Net::HTTP instance" do - @net.should be_kind_of(Net::HTTP) + @net.should.is_a?(Net::HTTP) end it "sets the new Net::HTTP instance's address to the passed address" do @@ -16,11 +16,11 @@ describe "Net::HTTP.newobj" do end it "sets the new Net::HTTP instance's port to the default HTTP port" do - @net.port.should eql(Net::HTTP.default_port) + @net.port.should.eql?(Net::HTTP.default_port) end it "does not start the new Net::HTTP instance" do - @net.started?.should be_false + @net.started?.should == false end end @@ -30,7 +30,7 @@ describe "Net::HTTP.newobj" do end it "returns a new Net::HTTP instance" do - @net.should be_kind_of(Net::HTTP) + @net.should.is_a?(Net::HTTP) end it "sets the new Net::HTTP instance's address to the passed address" do @@ -38,11 +38,11 @@ describe "Net::HTTP.newobj" do end it "sets the new Net::HTTP instance's port to the passed port" do - @net.port.should eql(3333) + @net.port.should.eql?(3333) end it "does not start the new Net::HTTP instance" do - @net.started?.should be_false + @net.started?.should == false end end end diff --git a/spec/ruby/library/net-http/http/open_timeout_spec.rb b/spec/ruby/library/net-http/http/open_timeout_spec.rb index 0d93752271..d00f844b38 100644 --- a/spec/ruby/library/net-http/http/open_timeout_spec.rb +++ b/spec/ruby/library/net-http/http/open_timeout_spec.rb @@ -4,9 +4,9 @@ require 'net/http' describe "Net::HTTP#open_timeout" do it "returns the seconds to wait till the connection is open" do net = Net::HTTP.new("localhost") - net.open_timeout.should eql(60) + net.open_timeout.should.eql?(60) net.open_timeout = 10 - net.open_timeout.should eql(10) + net.open_timeout.should.eql?(10) end end @@ -14,11 +14,11 @@ describe "Net::HTTP#open_timeout=" do it "sets the seconds to wait till the connection is open" do net = Net::HTTP.new("localhost") net.open_timeout = 10 - net.open_timeout.should eql(10) + net.open_timeout.should.eql?(10) end it "returns the newly set value" do net = Net::HTTP.new("localhost") - (net.open_timeout = 10).should eql(10) + (net.open_timeout = 10).should.eql?(10) end end diff --git a/spec/ruby/library/net-http/http/options_spec.rb b/spec/ruby/library/net-http/http/options_spec.rb index 3d9887a557..3b90573cfa 100644 --- a/spec/ruby/library/net-http/http/options_spec.rb +++ b/spec/ruby/library/net-http/http/options_spec.rb @@ -20,6 +20,6 @@ describe "Net::HTTP#options" do end it "returns a Net::HTTPResponse" do - @http.options("/request").should be_kind_of(Net::HTTPResponse) + @http.options("/request").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/port_spec.rb b/spec/ruby/library/net-http/http/port_spec.rb index 0984d5e6ce..edb689f9ca 100644 --- a/spec/ruby/library/net-http/http/port_spec.rb +++ b/spec/ruby/library/net-http/http/port_spec.rb @@ -4,6 +4,6 @@ require 'net/http' describe "Net::HTTP#port" do it "returns the current port number" do net = Net::HTTP.new("localhost", 3333) - net.port.should eql(3333) + net.port.should.eql?(3333) end end diff --git a/spec/ruby/library/net-http/http/post2_spec.rb b/spec/ruby/library/net-http/http/post2_spec.rb index abc998709f..68c2a9ea06 100644 --- a/spec/ruby/library/net-http/http/post2_spec.rb +++ b/spec/ruby/library/net-http/http/post2_spec.rb @@ -1,8 +1,8 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_post' describe "Net::HTTP#post2" do - it_behaves_like :net_http_request_post, :post2 + it "is an alias of Net::HTTP#request_post" do + Net::HTTP.instance_method(:post2).should == Net::HTTP.instance_method(:request_post) + end end diff --git a/spec/ruby/library/net-http/http/post_spec.rb b/spec/ruby/library/net-http/http/post_spec.rb index ac020bd6be..f294411197 100644 --- a/spec/ruby/library/net-http/http/post_spec.rb +++ b/spec/ruby/library/net-http/http/post_spec.rb @@ -22,12 +22,14 @@ describe "Net::HTTP.post" do it "returns a Net::HTTPResponse" do response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request"), "test=test") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end - it "sends Content-Type: application/x-www-form-urlencoded by default" do - response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test") - response.body.should include({ "Content-Type" => "application/x-www-form-urlencoded" }.inspect.delete("{}")) + ruby_version_is ""..."4.0" do + it "sends Content-Type: application/x-www-form-urlencoded by default" do + response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test") + response.body.should.include?({ "Content-Type" => "application/x-www-form-urlencoded" }.inspect.delete("{}")) + end end it "does not support HTTP Basic Auth" do @@ -55,7 +57,7 @@ describe "Net::HTTP#post" do end it "returns a Net::HTTPResponse" do - @http.post("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.post("/request", "test=test").should.is_a?(Net::HTTPResponse) end describe "when passed a block" do @@ -68,7 +70,7 @@ describe "Net::HTTP#post" do end it "returns a Net::HTTPResponse" do - @http.post("/request", "test=test") {}.should be_kind_of(Net::HTTPResponse) + @http.post("/request", "test=test") {}.should.is_a?(Net::HTTPResponse) end end end diff --git a/spec/ruby/library/net-http/http/propfind_spec.rb b/spec/ruby/library/net-http/http/propfind_spec.rb index f3742d1b1a..6a1be0392a 100644 --- a/spec/ruby/library/net-http/http/propfind_spec.rb +++ b/spec/ruby/library/net-http/http/propfind_spec.rb @@ -19,6 +19,6 @@ describe "Net::HTTP#propfind" do end it "returns a Net::HTTPResponse" do - @http.propfind("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.propfind("/request", "test=test").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/proppatch_spec.rb b/spec/ruby/library/net-http/http/proppatch_spec.rb index 0163d24d46..074dfafaef 100644 --- a/spec/ruby/library/net-http/http/proppatch_spec.rb +++ b/spec/ruby/library/net-http/http/proppatch_spec.rb @@ -19,6 +19,6 @@ describe "Net::HTTP#proppatch" do end it "returns a Net::HTTPResponse" do - @http.proppatch("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.proppatch("/request", "test=test").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/proxy_address_spec.rb b/spec/ruby/library/net-http/http/proxy_address_spec.rb index 5b5efb7ac0..ba040336ad 100644 --- a/spec/ruby/library/net-http/http/proxy_address_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_address_spec.rb @@ -4,7 +4,7 @@ require 'net/http' describe "Net::HTTP.proxy_address" do describe "when self is no proxy class" do it "returns nil" do - Net::HTTP.proxy_address.should be_nil + Net::HTTP.proxy_address.should == nil end end @@ -18,7 +18,7 @@ end describe "Net::HTTP#proxy_address" do describe "when self is no proxy class instance" do it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_address.should be_nil + Net::HTTP.new("localhost", 3333).proxy_address.should == nil end end diff --git a/spec/ruby/library/net-http/http/proxy_class_spec.rb b/spec/ruby/library/net-http/http/proxy_class_spec.rb index 00975aef4e..eda027c893 100644 --- a/spec/ruby/library/net-http/http/proxy_class_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_class_spec.rb @@ -3,7 +3,7 @@ require 'net/http' describe "Net::HTTP.proxy_class?" do it "returns true if self is a class created with Net::HTTP.Proxy" do - Net::HTTP.proxy_class?.should be_false - Net::HTTP.Proxy("localhost").proxy_class?.should be_true + Net::HTTP.proxy_class?.should == false + Net::HTTP.Proxy("localhost").proxy_class?.should == true end end diff --git a/spec/ruby/library/net-http/http/proxy_pass_spec.rb b/spec/ruby/library/net-http/http/proxy_pass_spec.rb index 4e393a53ff..ad02d896c0 100644 --- a/spec/ruby/library/net-http/http/proxy_pass_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_pass_spec.rb @@ -4,13 +4,13 @@ require 'net/http' describe "Net::HTTP.proxy_pass" do describe "when self is no proxy class" do it "returns nil" do - Net::HTTP.proxy_pass.should be_nil + Net::HTTP.proxy_pass.should == nil end end describe "when self is a proxy class" do it "returns nil if no password was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_pass.should be_nil + Net::HTTP.Proxy("localhost").proxy_pass.should == nil end it "returns the password for self's proxy connection" do @@ -22,13 +22,13 @@ end describe "Net::HTTP#proxy_pass" do describe "when self is no proxy class instance" do it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_pass.should be_nil + Net::HTTP.new("localhost", 3333).proxy_pass.should == nil end end describe "when self is a proxy class instance" do it "returns nil if no password was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_pass.should be_nil + Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_pass.should == nil end it "returns the password for self's proxy connection" do diff --git a/spec/ruby/library/net-http/http/proxy_port_spec.rb b/spec/ruby/library/net-http/http/proxy_port_spec.rb index d7d37f3927..21c1e4180e 100644 --- a/spec/ruby/library/net-http/http/proxy_port_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_port_spec.rb @@ -4,17 +4,17 @@ require 'net/http' describe "Net::HTTP.proxy_port" do describe "when self is no proxy class" do it "returns nil" do - Net::HTTP.proxy_port.should be_nil + Net::HTTP.proxy_port.should == nil end end describe "when self is a proxy class" do it "returns 80 if no port was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_port.should eql(80) + Net::HTTP.Proxy("localhost").proxy_port.should.eql?(80) end it "returns the port for self's proxy connection" do - Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks").proxy_port.should eql(1234) + Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks").proxy_port.should.eql?(1234) end end end @@ -22,18 +22,18 @@ end describe "Net::HTTP#proxy_port" do describe "when self is no proxy class instance" do it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_port.should be_nil + Net::HTTP.new("localhost", 3333).proxy_port.should == nil end end describe "when self is a proxy class instance" do it "returns 80 if no port was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_port.should eql(80) + Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_port.should.eql?(80) end it "returns the port for self's proxy connection" do http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy_port.should eql(1234) + http_with_proxy.new("localhost", 3333).proxy_port.should.eql?(1234) end end end diff --git a/spec/ruby/library/net-http/http/proxy_user_spec.rb b/spec/ruby/library/net-http/http/proxy_user_spec.rb index ef7654425d..492ea2e8ee 100644 --- a/spec/ruby/library/net-http/http/proxy_user_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_user_spec.rb @@ -4,13 +4,13 @@ require 'net/http' describe "Net::HTTP.proxy_user" do describe "when self is no proxy class" do it "returns nil" do - Net::HTTP.proxy_user.should be_nil + Net::HTTP.proxy_user.should == nil end end describe "when self is a proxy class" do it "returns nil if no username was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_user.should be_nil + Net::HTTP.Proxy("localhost").proxy_user.should == nil end it "returns the username for self's proxy connection" do @@ -22,13 +22,13 @@ end describe "Net::HTTP#proxy_user" do describe "when self is no proxy class instance" do it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_user.should be_nil + Net::HTTP.new("localhost", 3333).proxy_user.should == nil end end describe "when self is a proxy class instance" do it "returns nil if no username was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_user.should be_nil + Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_user.should == nil end it "returns the username for self's proxy connection" do diff --git a/spec/ruby/library/net-http/http/put2_spec.rb b/spec/ruby/library/net-http/http/put2_spec.rb index 7b03a39d0b..237df67e82 100644 --- a/spec/ruby/library/net-http/http/put2_spec.rb +++ b/spec/ruby/library/net-http/http/put2_spec.rb @@ -1,8 +1,8 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_put' describe "Net::HTTP#put2" do - it_behaves_like :net_http_request_put, :put2 + it "is an alias of Net::HTTP#request_put" do + Net::HTTP.instance_method(:put2).should == Net::HTTP.instance_method(:request_put) + end end diff --git a/spec/ruby/library/net-http/http/put_spec.rb b/spec/ruby/library/net-http/http/put_spec.rb index 75f3c243d4..7ef9219f63 100644 --- a/spec/ruby/library/net-http/http/put_spec.rb +++ b/spec/ruby/library/net-http/http/put_spec.rb @@ -19,6 +19,6 @@ describe "Net::HTTP#put" do end it "returns a Net::HTTPResponse" do - @http.put("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.put("/request", "test=test").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/read_timeout_spec.rb b/spec/ruby/library/net-http/http/read_timeout_spec.rb index 7a0d2f1d72..81e71337bb 100644 --- a/spec/ruby/library/net-http/http/read_timeout_spec.rb +++ b/spec/ruby/library/net-http/http/read_timeout_spec.rb @@ -4,9 +4,9 @@ require 'net/http' describe "Net::HTTP#read_timeout" do it "returns the seconds to wait until reading one block" do net = Net::HTTP.new("localhost") - net.read_timeout.should eql(60) + net.read_timeout.should.eql?(60) net.read_timeout = 10 - net.read_timeout.should eql(10) + net.read_timeout.should.eql?(10) end end @@ -14,11 +14,11 @@ describe "Net::HTTP#read_timeout=" do it "sets the seconds to wait till the connection is open" do net = Net::HTTP.new("localhost") net.read_timeout = 10 - net.read_timeout.should eql(10) + net.read_timeout.should.eql?(10) end it "returns the newly set value" do net = Net::HTTP.new("localhost") - (net.read_timeout = 10).should eql(10) + (net.read_timeout = 10).should.eql?(10) end end diff --git a/spec/ruby/library/net-http/http/request_get_spec.rb b/spec/ruby/library/net-http/http/request_get_spec.rb index 98025a14a1..1737e62439 100644 --- a/spec/ruby/library/net-http/http/request_get_spec.rb +++ b/spec/ruby/library/net-http/http/request_get_spec.rb @@ -1,8 +1,45 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/http_server' -require_relative 'shared/request_get' describe "Net::HTTP#request_get" do - it_behaves_like :net_http_request_get, :get2 + before :each do + NetHTTPSpecs.start_server + @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) + end + + after :each do + @http.finish if @http.started? + NetHTTPSpecs.stop_server + end + + describe "when passed no block" do + it "sends a GET request to the passed path and returns the response" do + response = @http.request_get("/request") + response.body.should == "Request type: GET" + end + + it "returns a Net::HTTPResponse object" do + response = @http.request_get("/request") + response.should.is_a?(Net::HTTPResponse) + end + end + + describe "when passed a block" do + it "sends a GET request to the passed path and returns the response" do + response = @http.request_get("/request") {} + response.body.should == "Request type: GET" + end + + it "yields the response to the passed block" do + @http.request_get("/request") do |response| + response.body.should == "Request type: GET" + end + end + + it "returns a Net::HTTPResponse object" do + response = @http.request_get("/request") {} + response.should.is_a?(Net::HTTPResponse) + end + end end diff --git a/spec/ruby/library/net-http/http/request_head_spec.rb b/spec/ruby/library/net-http/http/request_head_spec.rb index 8f514d4eee..7c46ebfc53 100644 --- a/spec/ruby/library/net-http/http/request_head_spec.rb +++ b/spec/ruby/library/net-http/http/request_head_spec.rb @@ -1,8 +1,45 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/http_server' -require_relative 'shared/request_head' describe "Net::HTTP#request_head" do - it_behaves_like :net_http_request_head, :request_head + before :each do + NetHTTPSpecs.start_server + @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) + end + + after :each do + @http.finish if @http.started? + NetHTTPSpecs.stop_server + end + + describe "when passed no block" do + it "sends a head request to the passed path and returns the response" do + response = @http.request_head("/request") + response.body.should == nil + end + + it "returns a Net::HTTPResponse object" do + response = @http.request_head("/request") + response.should.is_a?(Net::HTTPResponse) + end + end + + describe "when passed a block" do + it "sends a head request to the passed path and returns the response" do + response = @http.request_head("/request") {} + response.body.should == nil + end + + it "yields the response to the passed block" do + @http.request_head("/request") do |response| + response.body.should == nil + end + end + + it "returns a Net::HTTPResponse object" do + response = @http.request_head("/request") {} + response.should.is_a?(Net::HTTPResponse) + end + end end diff --git a/spec/ruby/library/net-http/http/request_post_spec.rb b/spec/ruby/library/net-http/http/request_post_spec.rb index 719bd5a7ee..8cfdd3469e 100644 --- a/spec/ruby/library/net-http/http/request_post_spec.rb +++ b/spec/ruby/library/net-http/http/request_post_spec.rb @@ -1,8 +1,45 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/http_server' -require_relative 'shared/request_post' describe "Net::HTTP#request_post" do - it_behaves_like :net_http_request_post, :request_post + before :each do + NetHTTPSpecs.start_server + @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) + end + + after :each do + @http.finish if @http.started? + NetHTTPSpecs.stop_server + end + + describe "when passed no block" do + it "sends a post request to the passed path and returns the response" do + response = @http.request_post("/request", "test=test") + response.body.should == "Request type: POST" + end + + it "returns a Net::HTTPResponse object" do + response = @http.request_post("/request", "test=test") + response.should.is_a?(Net::HTTPResponse) + end + end + + describe "when passed a block" do + it "sends a post request to the passed path and returns the response" do + response = @http.request_post("/request", "test=test") {} + response.body.should == "Request type: POST" + end + + it "yields the response to the passed block" do + @http.request_post("/request", "test=test") do |response| + response.body.should == "Request type: POST" + end + end + + it "returns a Net::HTTPResponse object" do + response = @http.request_post("/request", "test=test") {} + response.should.is_a?(Net::HTTPResponse) + end + end end diff --git a/spec/ruby/library/net-http/http/request_put_spec.rb b/spec/ruby/library/net-http/http/request_put_spec.rb index 9fcf3a98d6..b7388a21c8 100644 --- a/spec/ruby/library/net-http/http/request_put_spec.rb +++ b/spec/ruby/library/net-http/http/request_put_spec.rb @@ -1,8 +1,45 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/http_server' -require_relative 'shared/request_put' describe "Net::HTTP#request_put" do - it_behaves_like :net_http_request_put, :request_put + before :each do + NetHTTPSpecs.start_server + @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) + end + + after :each do + @http.finish if @http.started? + NetHTTPSpecs.stop_server + end + + describe "when passed no block" do + it "sends a put request to the passed path and returns the response" do + response = @http.request_put("/request", "test=test") + response.body.should == "Request type: PUT" + end + + it "returns a Net::HTTPResponse object" do + response = @http.request_put("/request", "test=test") + response.should.is_a?(Net::HTTPResponse) + end + end + + describe "when passed a block" do + it "sends a put request to the passed path and returns the response" do + response = @http.request_put("/request", "test=test") {} + response.body.should == "Request type: PUT" + end + + it "yields the response to the passed block" do + @http.request_put("/request", "test=test") do |response| + response.body.should == "Request type: PUT" + end + end + + it "returns a Net::HTTPResponse object" do + response = @http.request_put("/request", "test=test") {} + response.should.is_a?(Net::HTTPResponse) + end + end end diff --git a/spec/ruby/library/net-http/http/request_spec.rb b/spec/ruby/library/net-http/http/request_spec.rb index 356e605b3b..e05ee96b55 100644 --- a/spec/ruby/library/net-http/http/request_spec.rb +++ b/spec/ruby/library/net-http/http/request_spec.rb @@ -19,7 +19,7 @@ describe "Net::HTTP#request" do response.body.should == "Request type: GET" response = @http.request(Net::HTTP::Head.new("/request"), "test=test") - response.body.should be_nil + response.body.should == nil response = @http.request(Net::HTTP::Post.new("/request"), "test=test") response.body.should == "Request type: POST" @@ -38,7 +38,7 @@ describe "Net::HTTP#request" do # TODO: Does not work? #response = @http.request(Net::HTTP::Options.new("/request"), "test=test") - #response.body.should be_nil + #response.body.should == nil response = @http.request(Net::HTTP::Propfind.new("/request"), "test=test") response.body.should == "Request type: PROPFIND" @@ -66,7 +66,7 @@ describe "Net::HTTP#request" do response.body.should == "test=test" response = @http.request(Net::HTTP::Head.new("/request/body"), "test=test") - response.body.should be_nil + response.body.should == nil response = @http.request(Net::HTTP::Post.new("/request/body"), "test=test") response.body.should == "test=test" @@ -85,7 +85,7 @@ describe "Net::HTTP#request" do # TODO: Does not work? #response = @http.request(Net::HTTP::Options.new("/request/body"), "test=test") - #response.body.should be_nil + #response.body.should == nil response = @http.request(Net::HTTP::Propfind.new("/request/body"), "test=test") response.body.should == "test=test" diff --git a/spec/ruby/library/net-http/http/request_types_spec.rb b/spec/ruby/library/net-http/http/request_types_spec.rb index 53aef1ee58..0adc625979 100644 --- a/spec/ruby/library/net-http/http/request_types_spec.rb +++ b/spec/ruby/library/net-http/http/request_types_spec.rb @@ -11,11 +11,11 @@ describe "Net::HTTP::Get" do end it "has no Request Body" do - Net::HTTP::Get::REQUEST_HAS_BODY.should be_false + Net::HTTP::Get::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Get::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Get::RESPONSE_HAS_BODY.should == true end end @@ -29,11 +29,11 @@ describe "Net::HTTP::Head" do end it "has no Request Body" do - Net::HTTP::Head::REQUEST_HAS_BODY.should be_false + Net::HTTP::Head::REQUEST_HAS_BODY.should == false end it "has no Response Body" do - Net::HTTP::Head::RESPONSE_HAS_BODY.should be_false + Net::HTTP::Head::RESPONSE_HAS_BODY.should == false end end @@ -47,11 +47,11 @@ describe "Net::HTTP::Post" do end it "has a Request Body" do - Net::HTTP::Post::REQUEST_HAS_BODY.should be_true + Net::HTTP::Post::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Post::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Post::RESPONSE_HAS_BODY.should == true end end @@ -65,11 +65,11 @@ describe "Net::HTTP::Put" do end it "has a Request Body" do - Net::HTTP::Put::REQUEST_HAS_BODY.should be_true + Net::HTTP::Put::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Put::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Put::RESPONSE_HAS_BODY.should == true end end @@ -83,11 +83,11 @@ describe "Net::HTTP::Delete" do end it "has no Request Body" do - Net::HTTP::Delete::REQUEST_HAS_BODY.should be_false + Net::HTTP::Delete::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Delete::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Delete::RESPONSE_HAS_BODY.should == true end end @@ -101,11 +101,11 @@ describe "Net::HTTP::Options" do end it "has no Request Body" do - Net::HTTP::Options::REQUEST_HAS_BODY.should be_false + Net::HTTP::Options::REQUEST_HAS_BODY.should == false end it "has no Response Body" do - Net::HTTP::Options::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Options::RESPONSE_HAS_BODY.should == true end end @@ -119,11 +119,11 @@ describe "Net::HTTP::Trace" do end it "has no Request Body" do - Net::HTTP::Trace::REQUEST_HAS_BODY.should be_false + Net::HTTP::Trace::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Trace::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Trace::RESPONSE_HAS_BODY.should == true end end @@ -137,11 +137,11 @@ describe "Net::HTTP::Propfind" do end it "has a Request Body" do - Net::HTTP::Propfind::REQUEST_HAS_BODY.should be_true + Net::HTTP::Propfind::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Propfind::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Propfind::RESPONSE_HAS_BODY.should == true end end @@ -155,11 +155,11 @@ describe "Net::HTTP::Proppatch" do end it "has a Request Body" do - Net::HTTP::Proppatch::REQUEST_HAS_BODY.should be_true + Net::HTTP::Proppatch::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Proppatch::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Proppatch::RESPONSE_HAS_BODY.should == true end end @@ -173,11 +173,11 @@ describe "Net::HTTP::Mkcol" do end it "has a Request Body" do - Net::HTTP::Mkcol::REQUEST_HAS_BODY.should be_true + Net::HTTP::Mkcol::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Mkcol::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Mkcol::RESPONSE_HAS_BODY.should == true end end @@ -191,11 +191,11 @@ describe "Net::HTTP::Copy" do end it "has no Request Body" do - Net::HTTP::Copy::REQUEST_HAS_BODY.should be_false + Net::HTTP::Copy::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Copy::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Copy::RESPONSE_HAS_BODY.should == true end end @@ -209,11 +209,11 @@ describe "Net::HTTP::Move" do end it "has no Request Body" do - Net::HTTP::Move::REQUEST_HAS_BODY.should be_false + Net::HTTP::Move::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Move::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Move::RESPONSE_HAS_BODY.should == true end end @@ -227,11 +227,11 @@ describe "Net::HTTP::Lock" do end it "has a Request Body" do - Net::HTTP::Lock::REQUEST_HAS_BODY.should be_true + Net::HTTP::Lock::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Lock::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Lock::RESPONSE_HAS_BODY.should == true end end @@ -245,10 +245,10 @@ describe "Net::HTTP::Unlock" do end it "has a Request Body" do - Net::HTTP::Unlock::REQUEST_HAS_BODY.should be_true + Net::HTTP::Unlock::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Unlock::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Unlock::RESPONSE_HAS_BODY.should == true end end diff --git a/spec/ruby/library/net-http/http/send_request_spec.rb b/spec/ruby/library/net-http/http/send_request_spec.rb index af35c068ce..e2dfc505b6 100644 --- a/spec/ruby/library/net-http/http/send_request_spec.rb +++ b/spec/ruby/library/net-http/http/send_request_spec.rb @@ -24,7 +24,7 @@ describe "Net::HTTP#send_request" do describe "when passed type, path" do it "sends a HTTP Request of the passed type to the passed path" do response = @http.send_request("HEAD", "/request") - response.body.should be_nil + response.body.should == nil (@methods - %w[POST PUT]).each do |method| response = @http.send_request(method, "/request") @@ -36,7 +36,7 @@ describe "Net::HTTP#send_request" do describe "when passed type, path, body" do it "sends a HTTP Request with the passed body" do response = @http.send_request("HEAD", "/request/body", "test=test") - response.body.should be_nil + response.body.should == nil @methods.each do |method| response = @http.send_request(method, "/request/body", "test=test") @@ -50,11 +50,11 @@ describe "Net::HTTP#send_request" do referer = 'https://www.ruby-lang.org/'.freeze response = @http.send_request("HEAD", "/request/header", "test=test", "referer" => referer) - response.body.should be_nil + response.body.should == nil @methods.each do |method| response = @http.send_request(method, "/request/header", "test=test", "referer" => referer) - response.body.should include({ "Referer" => referer }.inspect.delete("{}")) + response.body.should.include?({ "Referer" => referer }.inspect.delete("{}")) end end end diff --git a/spec/ruby/library/net-http/http/set_debug_output_spec.rb b/spec/ruby/library/net-http/http/set_debug_output_spec.rb index 5ceecb39fb..491ac38b5d 100644 --- a/spec/ruby/library/net-http/http/set_debug_output_spec.rb +++ b/spec/ruby/library/net-http/http/set_debug_output_spec.rb @@ -19,7 +19,7 @@ describe "Net::HTTP#set_debug_output when passed io" do @http.set_debug_output(io) @http.start - io.string.should_not be_empty + io.string.should_not.empty? size = io.string.size @http.get("/") diff --git a/spec/ruby/library/net-http/http/shared/request_get.rb b/spec/ruby/library/net-http/http/shared/request_get.rb deleted file mode 100644 index d25f32049b..0000000000 --- a/spec/ruby/library/net-http/http/shared/request_get.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe :net_http_request_get, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed no block" do - it "sends a GET request to the passed path and returns the response" do - response = @http.send(@method, "/request") - response.body.should == "Request type: GET" - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request") - response.should be_kind_of(Net::HTTPResponse) - end - end - - describe "when passed a block" do - it "sends a GET request to the passed path and returns the response" do - response = @http.send(@method, "/request") {} - response.body.should == "Request type: GET" - end - - it "yields the response to the passed block" do - @http.send(@method, "/request") do |response| - response.body.should == "Request type: GET" - end - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request") {} - response.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net-http/http/shared/request_head.rb b/spec/ruby/library/net-http/http/shared/request_head.rb deleted file mode 100644 index 78b555884b..0000000000 --- a/spec/ruby/library/net-http/http/shared/request_head.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe :net_http_request_head, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed no block" do - it "sends a head request to the passed path and returns the response" do - response = @http.send(@method, "/request") - response.body.should be_nil - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request") - response.should be_kind_of(Net::HTTPResponse) - end - end - - describe "when passed a block" do - it "sends a head request to the passed path and returns the response" do - response = @http.send(@method, "/request") {} - response.body.should be_nil - end - - it "yields the response to the passed block" do - @http.send(@method, "/request") do |response| - response.body.should be_nil - end - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request") {} - response.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net-http/http/shared/request_post.rb b/spec/ruby/library/net-http/http/shared/request_post.rb deleted file mode 100644 index e832411c48..0000000000 --- a/spec/ruby/library/net-http/http/shared/request_post.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe :net_http_request_post, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed no block" do - it "sends a post request to the passed path and returns the response" do - response = @http.send(@method, "/request", "test=test") - response.body.should == "Request type: POST" - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) - end - end - - describe "when passed a block" do - it "sends a post request to the passed path and returns the response" do - response = @http.send(@method, "/request", "test=test") {} - response.body.should == "Request type: POST" - end - - it "yields the response to the passed block" do - @http.send(@method, "/request", "test=test") do |response| - response.body.should == "Request type: POST" - end - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request", "test=test") {} - response.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net-http/http/shared/request_put.rb b/spec/ruby/library/net-http/http/shared/request_put.rb deleted file mode 100644 index 3b902f4957..0000000000 --- a/spec/ruby/library/net-http/http/shared/request_put.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe :net_http_request_put, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed no block" do - it "sends a put request to the passed path and returns the response" do - response = @http.send(@method, "/request", "test=test") - response.body.should == "Request type: PUT" - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) - end - end - - describe "when passed a block" do - it "sends a put request to the passed path and returns the response" do - response = @http.send(@method, "/request", "test=test") {} - response.body.should == "Request type: PUT" - end - - it "yields the response to the passed block" do - @http.send(@method, "/request", "test=test") do |response| - response.body.should == "Request type: PUT" - end - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request", "test=test") {} - response.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net-http/http/shared/started.rb b/spec/ruby/library/net-http/http/shared/started.rb deleted file mode 100644 index 9ff6272c31..0000000000 --- a/spec/ruby/library/net-http/http/shared/started.rb +++ /dev/null @@ -1,26 +0,0 @@ -describe :net_http_started_p, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.new("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "returns true when self has been started" do - @http.start - @http.send(@method).should be_true - end - - it "returns false when self has not been started yet" do - @http.send(@method).should be_false - end - - it "returns false when self has been stopped again" do - @http.start - @http.finish - @http.send(@method).should be_false - end -end diff --git a/spec/ruby/library/net-http/http/shared/version_1_1.rb b/spec/ruby/library/net-http/http/shared/version_1_1.rb deleted file mode 100644 index db3d6a986d..0000000000 --- a/spec/ruby/library/net-http/http/shared/version_1_1.rb +++ /dev/null @@ -1,6 +0,0 @@ -describe :net_http_version_1_1_p, shared: true do - it "returns the state of net/http 1.1 features" do - Net::HTTP.version_1_2 - Net::HTTP.send(@method).should be_false - end -end diff --git a/spec/ruby/library/net-http/http/shared/version_1_2.rb b/spec/ruby/library/net-http/http/shared/version_1_2.rb deleted file mode 100644 index b044182c60..0000000000 --- a/spec/ruby/library/net-http/http/shared/version_1_2.rb +++ /dev/null @@ -1,6 +0,0 @@ -describe :net_http_version_1_2_p, shared: true do - it "returns the state of net/http 1.2 features" do - Net::HTTP.version_1_2 - Net::HTTP.send(@method).should be_true - end -end diff --git a/spec/ruby/library/net-http/http/start_spec.rb b/spec/ruby/library/net-http/http/start_spec.rb index 0ce3e79269..1aebc16f4d 100644 --- a/spec/ruby/library/net-http/http/start_spec.rb +++ b/spec/ruby/library/net-http/http/start_spec.rb @@ -22,13 +22,13 @@ describe "Net::HTTP.start" do end it "returns a new Net::HTTP object for the passed address and port" do - @http.should be_kind_of(Net::HTTP) + @http.should.is_a?(Net::HTTP) @http.address.should == "localhost" @http.port.should == @port end it "opens the tcp connection" do - @http.started?.should be_true + @http.started?.should == true end end @@ -41,19 +41,19 @@ describe "Net::HTTP.start" do yielded = false Net::HTTP.start("localhost", @port) do |net| yielded = true - net.should be_kind_of(Net::HTTP) + net.should.is_a?(Net::HTTP) end - yielded.should be_true + yielded.should == true end it "opens the tcp connection before yielding" do - Net::HTTP.start("localhost", @port) { |http| http.started?.should be_true } + Net::HTTP.start("localhost", @port) { |http| http.started?.should == true } end it "closes the tcp connection after yielding" do net = nil Net::HTTP.start("localhost", @port) { |x| net = x } - net.started?.should be_false + net.started?.should == false end end end @@ -70,18 +70,18 @@ describe "Net::HTTP#start" do end it "returns self" do - @http.start.should equal(@http) + @http.start.should.equal?(@http) end it "opens the tcp connection" do @http.start - @http.started?.should be_true + @http.started?.should == true end describe "when self has already been started" do it "raises an IOError" do @http.start - -> { @http.start }.should raise_error(IOError) + -> { @http.start }.should.raise(IOError) end end @@ -94,18 +94,18 @@ describe "Net::HTTP#start" do yielded = false @http.start do |http| yielded = true - http.should equal(@http) + http.should.equal?(@http) end - yielded.should be_true + yielded.should == true end it "opens the tcp connection before yielding" do - @http.start { |http| http.started?.should be_true } + @http.start { |http| http.started?.should == true } end it "closes the tcp connection after yielding" do @http.start { } - @http.started?.should be_false + @http.started?.should == false end end end diff --git a/spec/ruby/library/net-http/http/started_spec.rb b/spec/ruby/library/net-http/http/started_spec.rb index cbb82ceefa..a0b46fcbd2 100644 --- a/spec/ruby/library/net-http/http/started_spec.rb +++ b/spec/ruby/library/net-http/http/started_spec.rb @@ -1,8 +1,30 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/http_server' -require_relative 'shared/started' describe "Net::HTTP#started?" do - it_behaves_like :net_http_started_p, :started? + before :each do + NetHTTPSpecs.start_server + @http = Net::HTTP.new("localhost", NetHTTPSpecs.port) + end + + after :each do + @http.finish if @http.started? + NetHTTPSpecs.stop_server + end + + it "returns true when self has been started" do + @http.start + @http.started?.should == true + end + + it "returns false when self has not been started yet" do + @http.started?.should == false + end + + it "returns false when self has been stopped again" do + @http.start + @http.finish + @http.started?.should == false + end end diff --git a/spec/ruby/library/net-http/http/trace_spec.rb b/spec/ruby/library/net-http/http/trace_spec.rb index 9809d537c5..e0ff741b04 100644 --- a/spec/ruby/library/net-http/http/trace_spec.rb +++ b/spec/ruby/library/net-http/http/trace_spec.rb @@ -19,6 +19,6 @@ describe "Net::HTTP#trace" do end it "returns a Net::HTTPResponse" do - @http.trace("/request").should be_kind_of(Net::HTTPResponse) + @http.trace("/request").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/unlock_spec.rb b/spec/ruby/library/net-http/http/unlock_spec.rb index adf0b49f65..cbfc803f09 100644 --- a/spec/ruby/library/net-http/http/unlock_spec.rb +++ b/spec/ruby/library/net-http/http/unlock_spec.rb @@ -19,6 +19,6 @@ describe "Net::HTTP#unlock" do end it "returns a Net::HTTPResponse" do - @http.unlock("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.unlock("/request", "test=test").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/use_ssl_spec.rb b/spec/ruby/library/net-http/http/use_ssl_spec.rb index 912a62a8ba..b283655359 100644 --- a/spec/ruby/library/net-http/http/use_ssl_spec.rb +++ b/spec/ruby/library/net-http/http/use_ssl_spec.rb @@ -4,6 +4,6 @@ require 'net/http' describe "Net::HTTP#use_ssl?" do it "returns false" do http = Net::HTTP.new("localhost") - http.use_ssl?.should be_false + http.use_ssl?.should == false end end diff --git a/spec/ruby/library/net-http/http/version_1_1_spec.rb b/spec/ruby/library/net-http/http/version_1_1_spec.rb index 34a4ac8a6b..7f87bf30f9 100644 --- a/spec/ruby/library/net-http/http/version_1_1_spec.rb +++ b/spec/ruby/library/net-http/http/version_1_1_spec.rb @@ -1,7 +1,9 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'shared/version_1_1' describe "Net::HTTP.version_1_1?" do - it_behaves_like :net_http_version_1_1_p, :version_1_1? + it "returns the state of net/http 1.1 features" do + Net::HTTP.version_1_2 + Net::HTTP.version_1_1?.should == false + end end diff --git a/spec/ruby/library/net-http/http/version_1_2_spec.rb b/spec/ruby/library/net-http/http/version_1_2_spec.rb index e994511aea..73ca70ac7b 100644 --- a/spec/ruby/library/net-http/http/version_1_2_spec.rb +++ b/spec/ruby/library/net-http/http/version_1_2_spec.rb @@ -1,20 +1,22 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'shared/version_1_2' describe "Net::HTTP.version_1_2" do it "turns on net/http 1.2 features" do Net::HTTP.version_1_2 - Net::HTTP.version_1_2?.should be_true - Net::HTTP.version_1_1?.should be_false + Net::HTTP.version_1_2?.should == true + Net::HTTP.version_1_1?.should == false end it "returns true" do - Net::HTTP.version_1_2.should be_true + Net::HTTP.version_1_2.should == true end end describe "Net::HTTP.version_1_2?" do - it_behaves_like :net_http_version_1_2_p, :version_1_2? + it "returns the state of net/http 1.2 features" do + Net::HTTP.version_1_2 + Net::HTTP.version_1_2?.should == true + end end 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 diff --git a/spec/ruby/library/net-http/httpheader/canonical_each_spec.rb b/spec/ruby/library/net-http/httpheader/canonical_each_spec.rb index 64a5cae89e..c009e9f7ea 100644 --- a/spec/ruby/library/net-http/httpheader/canonical_each_spec.rb +++ b/spec/ruby/library/net-http/httpheader/canonical_each_spec.rb @@ -1,8 +1,9 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/each_capitalized' describe "Net::HTTPHeader#canonical_each" do - it_behaves_like :net_httpheader_each_capitalized, :canonical_each + it "is an alias of Net::HTTPHeader#each_capitalized" do + Net::HTTPHeader.instance_method(:canonical_each).should == + Net::HTTPHeader.instance_method(:each_capitalized) + end end diff --git a/spec/ruby/library/net-http/httpheader/chunked_spec.rb b/spec/ruby/library/net-http/httpheader/chunked_spec.rb index b32a0aab38..4da218ae25 100644 --- a/spec/ruby/library/net-http/httpheader/chunked_spec.rb +++ b/spec/ruby/library/net-http/httpheader/chunked_spec.rb @@ -8,15 +8,15 @@ describe "Net::HTTPHeader#chunked?" do end it "returns true if the 'Transfer-Encoding' header entry is set to chunked" do - @headers.chunked?.should be_false + @headers.chunked?.should == false @headers["Transfer-Encoding"] = "bla" - @headers.chunked?.should be_false + @headers.chunked?.should == false @headers["Transfer-Encoding"] = "blachunkedbla" - @headers.chunked?.should be_false + @headers.chunked?.should == false @headers["Transfer-Encoding"] = "chunked" - @headers.chunked?.should be_true + @headers.chunked?.should == true end end diff --git a/spec/ruby/library/net-http/httpheader/content_length_spec.rb b/spec/ruby/library/net-http/httpheader/content_length_spec.rb index f05c5f8d8b..c66d5673c1 100644 --- a/spec/ruby/library/net-http/httpheader/content_length_spec.rb +++ b/spec/ruby/library/net-http/httpheader/content_length_spec.rb @@ -8,23 +8,23 @@ describe "Net::HTTPHeader#content_length" do end it "returns nil if no 'Content-Length' header entry is set" do - @headers.content_length.should be_nil + @headers.content_length.should == nil end it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Length' header entry has an invalid format" do @headers["Content-Length"] = "invalid" - -> { @headers.content_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_length }.should.raise(Net::HTTPHeaderSyntaxError) end it "returns the value of the 'Content-Length' header entry as an Integer" do @headers["Content-Length"] = "123" - @headers.content_length.should eql(123) + @headers.content_length.should.eql?(123) @headers["Content-Length"] = "123valid" - @headers.content_length.should eql(123) + @headers.content_length.should.eql?(123) @headers["Content-Length"] = "valid123" - @headers.content_length.should eql(123) + @headers.content_length.should.eql?(123) end end @@ -36,7 +36,7 @@ describe "Net::HTTPHeader#content_length=" do it "removes the 'Content-Length' entry if passed false or nil" do @headers["Content-Length"] = "123" @headers.content_length = nil - @headers["Content-Length"].should be_nil + @headers["Content-Length"].should == nil end it "sets the 'Content-Length' entry to the passed value" do diff --git a/spec/ruby/library/net-http/httpheader/content_range_spec.rb b/spec/ruby/library/net-http/httpheader/content_range_spec.rb index 09737141a5..3635fb3f1b 100644 --- a/spec/ruby/library/net-http/httpheader/content_range_spec.rb +++ b/spec/ruby/library/net-http/httpheader/content_range_spec.rb @@ -16,17 +16,17 @@ describe "Net::HTTPHeader#content_range" do end it "returns nil when there is no 'Content-Range' header entry" do - @headers.content_range.should be_nil + @headers.content_range.should == nil end it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do @headers["Content-Range"] = "invalid" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes 123-abc" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes abc-123" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should.raise(Net::HTTPHeaderSyntaxError) end end diff --git a/spec/ruby/library/net-http/httpheader/content_type_spec.rb b/spec/ruby/library/net-http/httpheader/content_type_spec.rb index a6e1ae1093..0ee43a6942 100644 --- a/spec/ruby/library/net-http/httpheader/content_type_spec.rb +++ b/spec/ruby/library/net-http/httpheader/content_type_spec.rb @@ -1,7 +1,6 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/set_content_type' describe "Net::HTTPHeader#content_type" do before :each do @@ -17,10 +16,13 @@ describe "Net::HTTPHeader#content_type" do end it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.content_type.should be_nil + @headers.content_type.should == nil end end describe "Net::HTTPHeader#content_type=" do - it_behaves_like :net_httpheader_set_content_type, :content_type= + it "is an alias of Net::HTTPHeader#set_content_type" do + Net::HTTPHeader.instance_method(:content_type=).should == + Net::HTTPHeader.instance_method(:set_content_type) + end end diff --git a/spec/ruby/library/net-http/httpheader/delete_spec.rb b/spec/ruby/library/net-http/httpheader/delete_spec.rb index 8d929dbd86..09bae65a13 100644 --- a/spec/ruby/library/net-http/httpheader/delete_spec.rb +++ b/spec/ruby/library/net-http/httpheader/delete_spec.rb @@ -11,8 +11,8 @@ describe "Net::HTTPHeader#delete when passed key" do @headers["My-Header"] = "test" @headers.delete("My-Header") - @headers["My-Header"].should be_nil - @headers.size.should eql(0) + @headers["My-Header"].should == nil + @headers.size.should.eql?(0) end it "returns the removed values" do @@ -24,7 +24,7 @@ describe "Net::HTTPHeader#delete when passed key" do @headers["My-Header"] = "test" @headers.delete("my-header") - @headers["My-Header"].should be_nil - @headers.size.should eql(0) + @headers["My-Header"].should == nil + @headers.size.should.eql?(0) end end diff --git a/spec/ruby/library/net-http/httpheader/each_capitalized_name_spec.rb b/spec/ruby/library/net-http/httpheader/each_capitalized_name_spec.rb index 27713577f9..54874c0535 100644 --- a/spec/ruby/library/net-http/httpheader/each_capitalized_name_spec.rb +++ b/spec/ruby/library/net-http/httpheader/each_capitalized_name_spec.rb @@ -23,7 +23,7 @@ describe "Net::HTTPHeader#each_capitalized_name" do describe "when passed no block" do it "returns an Enumerator" do enumerator = @headers.each_capitalized_name - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) res = [] enumerator.each do |key| diff --git a/spec/ruby/library/net-http/httpheader/each_capitalized_spec.rb b/spec/ruby/library/net-http/httpheader/each_capitalized_spec.rb index 1e853995ea..e24e778238 100644 --- a/spec/ruby/library/net-http/httpheader/each_capitalized_spec.rb +++ b/spec/ruby/library/net-http/httpheader/each_capitalized_spec.rb @@ -1,8 +1,35 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/each_capitalized' describe "Net::HTTPHeader#each_capitalized" do - it_behaves_like :net_httpheader_each_capitalized, :each_capitalized + before :each do + @headers = NetHTTPHeaderSpecs::Example.new + @headers["my-header"] = "test" + @headers.add_field("my-Other-Header", "a") + @headers.add_field("My-Other-header", "b") + end + + describe "when passed a block" do + it "yields each header entry to the passed block (capitalized keys, values joined)" do + res = [] + @headers.each_capitalized do |key, value| + res << [key, value] + end + res.sort.should == [["My-Header", "test"], ["My-Other-Header", "a, b"]] + end + end + + describe "when passed no block" do + it "returns an Enumerator" do + enumerator = @headers.each_capitalized + enumerator.should.instance_of?(Enumerator) + + res = [] + enumerator.each do |*key| + res << key + end + res.sort.should == [["My-Header", "test"], ["My-Other-Header", "a, b"]] + end + end end diff --git a/spec/ruby/library/net-http/httpheader/each_header_spec.rb b/spec/ruby/library/net-http/httpheader/each_header_spec.rb index 869feebacf..63c1106d18 100644 --- a/spec/ruby/library/net-http/httpheader/each_header_spec.rb +++ b/spec/ruby/library/net-http/httpheader/each_header_spec.rb @@ -1,8 +1,35 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/each_header' describe "Net::HTTPHeader#each_header" do - it_behaves_like :net_httpheader_each_header, :each_header + before :each do + @headers = NetHTTPHeaderSpecs::Example.new + @headers["My-Header"] = "test" + @headers.add_field("My-Other-Header", "a") + @headers.add_field("My-Other-Header", "b") + end + + describe "when passed a block" do + it "yields each header entry to the passed block (keys in lower case, values joined)" do + res = [] + @headers.each_header do |key, value| + res << [key, value] + end + res.sort.should == [["my-header", "test"], ["my-other-header", "a, b"]] + end + end + + describe "when passed no block" do + it "returns an Enumerator" do + enumerator = @headers.each_header + enumerator.should.instance_of?(Enumerator) + + res = [] + enumerator.each do |*key| + res << key + end + res.sort.should == [["my-header", "test"], ["my-other-header", "a, b"]] + end + end end diff --git a/spec/ruby/library/net-http/httpheader/each_key_spec.rb b/spec/ruby/library/net-http/httpheader/each_key_spec.rb index 1ad145629f..a5635da5db 100644 --- a/spec/ruby/library/net-http/httpheader/each_key_spec.rb +++ b/spec/ruby/library/net-http/httpheader/each_key_spec.rb @@ -1,8 +1,35 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/each_name' describe "Net::HTTPHeader#each_key" do - it_behaves_like :net_httpheader_each_name, :each_key + before :each do + @headers = NetHTTPHeaderSpecs::Example.new + @headers["My-Header"] = "test" + @headers.add_field("My-Other-Header", "a") + @headers.add_field("My-Other-Header", "b") + end + + describe "when passed a block" do + it "yields each header key to the passed block (keys in lower case)" do + res = [] + @headers.each_key do |key| + res << key + end + res.sort.should == ["my-header", "my-other-header"] + end + end + + describe "when passed no block" do + it "returns an Enumerator" do + enumerator = @headers.each_key + enumerator.should.instance_of?(Enumerator) + + res = [] + enumerator.each do |key| + res << key + end + res.sort.should == ["my-header", "my-other-header"] + end + end end diff --git a/spec/ruby/library/net-http/httpheader/each_name_spec.rb b/spec/ruby/library/net-http/httpheader/each_name_spec.rb index f819bd989d..02f9761f80 100644 --- a/spec/ruby/library/net-http/httpheader/each_name_spec.rb +++ b/spec/ruby/library/net-http/httpheader/each_name_spec.rb @@ -1,8 +1,10 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/each_name' describe "Net::HTTPHeader#each_name" do - it_behaves_like :net_httpheader_each_name, :each_name + it "is an alias of Net::HTTPHeader#each_key" do + Net::HTTPHeader.instance_method(:each_name).should == + Net::HTTPHeader.instance_method(:each_key) + end end diff --git a/spec/ruby/library/net-http/httpheader/each_spec.rb b/spec/ruby/library/net-http/httpheader/each_spec.rb index ff37249d0a..e219609b67 100644 --- a/spec/ruby/library/net-http/httpheader/each_spec.rb +++ b/spec/ruby/library/net-http/httpheader/each_spec.rb @@ -1,8 +1,9 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/each_header' describe "Net::HTTPHeader#each" do - it_behaves_like :net_httpheader_each_header, :each + it "is an alias of Net::HTTPHeader#each_header" do + Net::HTTPHeader.instance_method(:each).should == + Net::HTTPHeader.instance_method(:each_header) + end end diff --git a/spec/ruby/library/net-http/httpheader/each_value_spec.rb b/spec/ruby/library/net-http/httpheader/each_value_spec.rb index b71df58c65..55ba4c1ef8 100644 --- a/spec/ruby/library/net-http/httpheader/each_value_spec.rb +++ b/spec/ruby/library/net-http/httpheader/each_value_spec.rb @@ -23,7 +23,7 @@ describe "Net::HTTPHeader#each_value" do describe "when passed no block" do it "returns an Enumerator" do enumerator = @headers.each_value - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) res = [] enumerator.each do |key| diff --git a/spec/ruby/library/net-http/httpheader/element_reference_spec.rb b/spec/ruby/library/net-http/httpheader/element_reference_spec.rb index 1003c41af9..f12f8494db 100644 --- a/spec/ruby/library/net-http/httpheader/element_reference_spec.rb +++ b/spec/ruby/library/net-http/httpheader/element_reference_spec.rb @@ -33,7 +33,7 @@ describe "Net::HTTPHeader#[] when passed key" do end it "returns nil for non-existing entries" do - @headers["My-Header"].should be_nil - @headers["My-Other-Header"].should be_nil + @headers["My-Header"].should == nil + @headers["My-Other-Header"].should == nil end end diff --git a/spec/ruby/library/net-http/httpheader/element_set_spec.rb b/spec/ruby/library/net-http/httpheader/element_set_spec.rb index 376df2f977..633fe18b2e 100644 --- a/spec/ruby/library/net-http/httpheader/element_set_spec.rb +++ b/spec/ruby/library/net-http/httpheader/element_set_spec.rb @@ -26,16 +26,16 @@ describe "Net::HTTPHeader#[]= when passed key, value" do @headers['MY-HEADER'] = "last one" @headers["My-Header"].should == "last one" - @headers.size.should eql(1) + @headers.size.should.eql?(1) end it "removes the header entry with the passed key when the value is false or nil" do @headers['My-Header'] = "test" @headers['My-Header'] = nil - @headers['My-Header'].should be_nil + @headers['My-Header'].should == nil @headers['My-Header'] = "test" @headers['My-Header'] = false - @headers['My-Header'].should be_nil + @headers['My-Header'].should == nil end end diff --git a/spec/ruby/library/net-http/httpheader/fetch_spec.rb b/spec/ruby/library/net-http/httpheader/fetch_spec.rb index 58c69c0377..d1c273dada 100644 --- a/spec/ruby/library/net-http/httpheader/fetch_spec.rb +++ b/spec/ruby/library/net-http/httpheader/fetch_spec.rb @@ -25,7 +25,7 @@ describe "Net::HTTPHeader#fetch" do end it "returns nil when there is no entry for the passed key" do - -> { @headers.fetch("my-header") }.should raise_error(IndexError) + -> { @headers.fetch("my-header") }.should.raise(IndexError) end end diff --git a/spec/ruby/library/net-http/httpheader/form_data_spec.rb b/spec/ruby/library/net-http/httpheader/form_data_spec.rb index acd913f53a..8d4974cde3 100644 --- a/spec/ruby/library/net-http/httpheader/form_data_spec.rb +++ b/spec/ruby/library/net-http/httpheader/form_data_spec.rb @@ -1,8 +1,10 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/set_form_data' describe "Net::HTTPHeader#form_data=" do - it_behaves_like :net_httpheader_set_form_data, :form_data= + it "is an alias of Net::HTTPHeader#set_form_data" do + Net::HTTPHeader.instance_method(:form_data=).should == + Net::HTTPHeader.instance_method(:set_form_data) + end end diff --git a/spec/ruby/library/net-http/httpheader/get_fields_spec.rb b/spec/ruby/library/net-http/httpheader/get_fields_spec.rb index 0278bcede2..76da63bc31 100644 --- a/spec/ruby/library/net-http/httpheader/get_fields_spec.rb +++ b/spec/ruby/library/net-http/httpheader/get_fields_spec.rb @@ -26,8 +26,8 @@ describe "Net::HTTPHeader#get_fields when passed key" do end it "returns nil for non-existing header entries" do - @headers.get_fields("My-Header").should be_nil - @headers.get_fields("My-Other-header").should be_nil + @headers.get_fields("My-Header").should == nil + @headers.get_fields("My-Other-header").should == nil end it "is case-insensitive" do diff --git a/spec/ruby/library/net-http/httpheader/key_spec.rb b/spec/ruby/library/net-http/httpheader/key_spec.rb index 2b7aeb9c2a..65662591eb 100644 --- a/spec/ruby/library/net-http/httpheader/key_spec.rb +++ b/spec/ruby/library/net-http/httpheader/key_spec.rb @@ -8,14 +8,14 @@ describe "Net::HTTPHeader#key? when passed key" do end it "returns true if the header entry with the passed key exists" do - @headers.key?("My-Header").should be_false + @headers.key?("My-Header").should == false @headers["My-Header"] = "test" - @headers.key?("My-Header").should be_true + @headers.key?("My-Header").should == true end it "is case-insensitive" do @headers["My-Header"] = "test" - @headers.key?("my-header").should be_true - @headers.key?("MY-HEADER").should be_true + @headers.key?("my-header").should == true + @headers.key?("MY-HEADER").should == true end end diff --git a/spec/ruby/library/net-http/httpheader/length_spec.rb b/spec/ruby/library/net-http/httpheader/length_spec.rb index 57e32742e4..1f059719e9 100644 --- a/spec/ruby/library/net-http/httpheader/length_spec.rb +++ b/spec/ruby/library/net-http/httpheader/length_spec.rb @@ -1,8 +1,9 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/size' describe "Net::HTTPHeader#length" do - it_behaves_like :net_httpheader_size, :length + it "is an alias of Net::HTTPHeader#size" do + Net::HTTPHeader.instance_method(:length).should == + Net::HTTPHeader.instance_method(:size) + end end diff --git a/spec/ruby/library/net-http/httpheader/main_type_spec.rb b/spec/ruby/library/net-http/httpheader/main_type_spec.rb index 4dd551d8f4..af7d3e05a3 100644 --- a/spec/ruby/library/net-http/httpheader/main_type_spec.rb +++ b/spec/ruby/library/net-http/httpheader/main_type_spec.rb @@ -19,6 +19,6 @@ describe "Net::HTTPHeader#main_type" do end it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.main_type.should be_nil + @headers.main_type.should == nil end end diff --git a/spec/ruby/library/net-http/httpheader/range_length_spec.rb b/spec/ruby/library/net-http/httpheader/range_length_spec.rb index 77323ac872..34db7e6126 100644 --- a/spec/ruby/library/net-http/httpheader/range_length_spec.rb +++ b/spec/ruby/library/net-http/httpheader/range_length_spec.rb @@ -9,24 +9,24 @@ describe "Net::HTTPHeader#range_length" do it "returns the length of the Range represented by the 'Content-Range' header entry" do @headers["Content-Range"] = "bytes 0-499/1234" - @headers.range_length.should eql(500) + @headers.range_length.should.eql?(500) @headers["Content-Range"] = "bytes 500-1233/1234" - @headers.range_length.should eql(734) + @headers.range_length.should.eql?(734) end it "returns nil when there is no 'Content-Range' header entry" do - @headers.range_length.should be_nil + @headers.range_length.should == nil end it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do @headers["Content-Range"] = "invalid" - -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes 123-abc" - -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes abc-123" - -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should.raise(Net::HTTPHeaderSyntaxError) end end diff --git a/spec/ruby/library/net-http/httpheader/range_spec.rb b/spec/ruby/library/net-http/httpheader/range_spec.rb index 2de80a825e..8944e2d5f2 100644 --- a/spec/ruby/library/net-http/httpheader/range_spec.rb +++ b/spec/ruby/library/net-http/httpheader/range_spec.rb @@ -1,7 +1,6 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/set_range' describe "Net::HTTPHeader#range" do before :each do @@ -23,26 +22,29 @@ describe "Net::HTTPHeader#range" do end it "returns nil when there is no 'Range' header entry" do - @headers.range.should be_nil + @headers.range.should == nil end it "raises a Net::HTTPHeaderSyntaxError when the 'Range' has an invalid format" do @headers["Range"] = "invalid" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Range"] = "bytes 123-abc" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Range"] = "bytes abc-123" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should.raise(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when the 'Range' was not specified" do @headers["Range"] = "bytes=-" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should.raise(Net::HTTPHeaderSyntaxError) end end describe "Net::HTTPHeader#range=" do - it_behaves_like :net_httpheader_set_range, :range= + it "is an alias of Net::HTTPHeader#set_range" do + Net::HTTPHeader.instance_method(:range=).should == + Net::HTTPHeader.instance_method(:set_range) + end end diff --git a/spec/ruby/library/net-http/httpheader/set_content_type_spec.rb b/spec/ruby/library/net-http/httpheader/set_content_type_spec.rb index 7ec4f90b8e..3674061626 100644 --- a/spec/ruby/library/net-http/httpheader/set_content_type_spec.rb +++ b/spec/ruby/library/net-http/httpheader/set_content_type_spec.rb @@ -1,8 +1,22 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/set_content_type' describe "Net::HTTPHeader#set_content_type" do - it_behaves_like :net_httpheader_set_content_type, :set_content_type + describe "when passed type, params" do + before :each do + @headers = NetHTTPHeaderSpecs::Example.new + end + + it "sets the 'Content-Type' header entry based on the passed type and params" do + @headers.set_content_type("text/html") + @headers["Content-Type"].should == "text/html" + + @headers.set_content_type("text/html", "charset" => "utf-8") + @headers["Content-Type"].should == "text/html; charset=utf-8" + + @headers.set_content_type("text/html", "charset" => "utf-8", "rubyspec" => "rocks") + @headers["Content-Type"].split(/; /).sort.should == %w[charset=utf-8 rubyspec=rocks text/html] + end + end end diff --git a/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb b/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb index 7aac19f045..093dc100d5 100644 --- a/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb +++ b/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb @@ -1,8 +1,31 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/set_form_data' describe "Net::HTTPHeader#set_form_data" do - it_behaves_like :net_httpheader_set_form_data, :set_form_data + before :each do + @headers = NetHTTPHeaderSpecs::Example.new + end + + describe "when passed params" do + it "automatically set the 'Content-Type' to 'application/x-www-form-urlencoded'" do + @headers.set_form_data("cmd" => "search", "q" => "ruby", "max" => "50") + @headers["Content-Type"].should == "application/x-www-form-urlencoded" + end + + it "sets self's body based on the passed form parameters" do + @headers.set_form_data("cmd" => "search", "q" => "ruby", "max" => "50") + @headers.body.split("&").sort.should == ["cmd=search", "max=50", "q=ruby"] + end + end + + describe "when passed params, separator" do + it "sets self's body based on the passed form parameters and the passed separator" do + @headers.set_form_data({"cmd" => "search", "q" => "ruby", "max" => "50"}, "&") + @headers.body.split("&").sort.should == ["cmd=search", "max=50", "q=ruby"] + + @headers.set_form_data({"cmd" => "search", "q" => "ruby", "max" => "50"}, ";") + @headers.body.split(";").sort.should == ["cmd=search", "max=50", "q=ruby"] + end + end end diff --git a/spec/ruby/library/net-http/httpheader/set_range_spec.rb b/spec/ruby/library/net-http/httpheader/set_range_spec.rb index 0f98de55e6..d48ed1897a 100644 --- a/spec/ruby/library/net-http/httpheader/set_range_spec.rb +++ b/spec/ruby/library/net-http/httpheader/set_range_spec.rb @@ -1,8 +1,93 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/set_range' describe "Net::HTTPHeader#set_range" do - it_behaves_like :net_httpheader_set_range, :set_range + before :each do + @headers = NetHTTPHeaderSpecs::Example.new + end + + describe "when passed nil" do + it "returns nil" do + @headers.set_range(nil).should == nil + end + + it "deletes the 'Range' header entry" do + @headers["Range"] = "bytes 0-499/1234" + @headers.set_range(nil) + @headers["Range"].should == nil + end + end + + describe "when passed Numeric" do + it "sets the 'Range' header entry based on the passed Numeric" do + @headers.set_range(10) + @headers["Range"].should == "bytes=0-9" + + @headers.set_range(-10) + @headers["Range"].should == "bytes=-10" + + @headers.set_range(10.9) + @headers["Range"].should == "bytes=0-9" + end + end + + describe "when passed Range" do + it "sets the 'Range' header entry based on the passed Range" do + @headers.set_range(10..200) + @headers["Range"].should == "bytes=10-200" + + @headers.set_range(1..5) + @headers["Range"].should == "bytes=1-5" + + @headers.set_range(1...5) + @headers["Range"].should == "bytes=1-4" + + @headers.set_range(234..567) + @headers["Range"].should == "bytes=234-567" + + @headers.set_range(-5..-1) + @headers["Range"].should == "bytes=-5" + + @headers.set_range(1..-1) + @headers["Range"].should == "bytes=1-" + end + + it "raises a Net::HTTPHeaderSyntaxError when the first Range element is negative" do + -> { @headers.set_range(-10..5) }.should.raise(Net::HTTPHeaderSyntaxError) + end + + it "raises a Net::HTTPHeaderSyntaxError when the last Range element is negative" do + -> { @headers.set_range(10..-5) }.should.raise(Net::HTTPHeaderSyntaxError) + end + + it "raises a Net::HTTPHeaderSyntaxError when the last Range element is smaller than the first" do + -> { @headers.set_range(10..5) }.should.raise(Net::HTTPHeaderSyntaxError) + end + end + + describe "when passed start, end" do + it "sets the 'Range' header entry based on the passed start and length values" do + @headers.set_range(10, 200) + @headers["Range"].should == "bytes=10-209" + + @headers.set_range(1, 5) + @headers["Range"].should == "bytes=1-5" + + @headers.set_range(234, 567) + @headers["Range"].should == "bytes=234-800" + end + + it "raises a Net::HTTPHeaderSyntaxError when start is negative" do + -> { @headers.set_range(-10, 5) }.should.raise(Net::HTTPHeaderSyntaxError) + end + + it "raises a Net::HTTPHeaderSyntaxError when start + length is negative" do + -> { @headers.set_range(10, -15) }.should.raise(Net::HTTPHeaderSyntaxError) + end + + it "raises a Net::HTTPHeaderSyntaxError when length is negative" do + -> { @headers.set_range(10, -4) }.should.raise(Net::HTTPHeaderSyntaxError) + end + end end diff --git a/spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb b/spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb deleted file mode 100644 index 3bac409876..0000000000 --- a/spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb +++ /dev/null @@ -1,31 +0,0 @@ -describe :net_httpheader_each_capitalized, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - @headers["my-header"] = "test" - @headers.add_field("my-Other-Header", "a") - @headers.add_field("My-Other-header", "b") - end - - describe "when passed a block" do - it "yields each header entry to the passed block (capitalized keys, values joined)" do - res = [] - @headers.send(@method) do |key, value| - res << [key, value] - end - res.sort.should == [["My-Header", "test"], ["My-Other-Header", "a, b"]] - end - end - - describe "when passed no block" do - it "returns an Enumerator" do - enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) - - res = [] - enumerator.each do |*key| - res << key - end - res.sort.should == [["My-Header", "test"], ["My-Other-Header", "a, b"]] - end - end -end diff --git a/spec/ruby/library/net-http/httpheader/shared/each_header.rb b/spec/ruby/library/net-http/httpheader/shared/each_header.rb deleted file mode 100644 index 6bf3a6ddfe..0000000000 --- a/spec/ruby/library/net-http/httpheader/shared/each_header.rb +++ /dev/null @@ -1,31 +0,0 @@ -describe :net_httpheader_each_header, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - @headers["My-Header"] = "test" - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - end - - describe "when passed a block" do - it "yields each header entry to the passed block (keys in lower case, values joined)" do - res = [] - @headers.send(@method) do |key, value| - res << [key, value] - end - res.sort.should == [["my-header", "test"], ["my-other-header", "a, b"]] - end - end - - describe "when passed no block" do - it "returns an Enumerator" do - enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) - - res = [] - enumerator.each do |*key| - res << key - end - res.sort.should == [["my-header", "test"], ["my-other-header", "a, b"]] - end - end -end diff --git a/spec/ruby/library/net-http/httpheader/shared/each_name.rb b/spec/ruby/library/net-http/httpheader/shared/each_name.rb deleted file mode 100644 index efc6a09dfd..0000000000 --- a/spec/ruby/library/net-http/httpheader/shared/each_name.rb +++ /dev/null @@ -1,31 +0,0 @@ -describe :net_httpheader_each_name, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - @headers["My-Header"] = "test" - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - end - - describe "when passed a block" do - it "yields each header key to the passed block (keys in lower case)" do - res = [] - @headers.send(@method) do |key| - res << key - end - res.sort.should == ["my-header", "my-other-header"] - end - end - - describe "when passed no block" do - it "returns an Enumerator" do - enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) - - res = [] - enumerator.each do |key| - res << key - end - res.sort.should == ["my-header", "my-other-header"] - end - end -end diff --git a/spec/ruby/library/net-http/httpheader/shared/set_content_type.rb b/spec/ruby/library/net-http/httpheader/shared/set_content_type.rb deleted file mode 100644 index b7359bdca6..0000000000 --- a/spec/ruby/library/net-http/httpheader/shared/set_content_type.rb +++ /dev/null @@ -1,18 +0,0 @@ -describe :net_httpheader_set_content_type, shared: true do - describe "when passed type, params" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "sets the 'Content-Type' header entry based on the passed type and params" do - @headers.send(@method, "text/html") - @headers["Content-Type"].should == "text/html" - - @headers.send(@method, "text/html", "charset" => "utf-8") - @headers["Content-Type"].should == "text/html; charset=utf-8" - - @headers.send(@method, "text/html", "charset" => "utf-8", "rubyspec" => "rocks") - @headers["Content-Type"].split(/; /).sort.should == %w[charset=utf-8 rubyspec=rocks text/html] - end - end -end diff --git a/spec/ruby/library/net-http/httpheader/shared/set_form_data.rb b/spec/ruby/library/net-http/httpheader/shared/set_form_data.rb deleted file mode 100644 index db20b18803..0000000000 --- a/spec/ruby/library/net-http/httpheader/shared/set_form_data.rb +++ /dev/null @@ -1,27 +0,0 @@ -describe :net_httpheader_set_form_data, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - describe "when passed params" do - it "automatically set the 'Content-Type' to 'application/x-www-form-urlencoded'" do - @headers.send(@method, "cmd" => "search", "q" => "ruby", "max" => "50") - @headers["Content-Type"].should == "application/x-www-form-urlencoded" - end - - it "sets self's body based on the passed form parameters" do - @headers.send(@method, "cmd" => "search", "q" => "ruby", "max" => "50") - @headers.body.split("&").sort.should == ["cmd=search", "max=50", "q=ruby"] - end - end - - describe "when passed params, separator" do - it "sets self's body based on the passed form parameters and the passed separator" do - @headers.send(@method, {"cmd" => "search", "q" => "ruby", "max" => "50"}, "&") - @headers.body.split("&").sort.should == ["cmd=search", "max=50", "q=ruby"] - - @headers.send(@method, {"cmd" => "search", "q" => "ruby", "max" => "50"}, ";") - @headers.body.split(";").sort.should == ["cmd=search", "max=50", "q=ruby"] - end - end -end diff --git a/spec/ruby/library/net-http/httpheader/shared/set_range.rb b/spec/ruby/library/net-http/httpheader/shared/set_range.rb deleted file mode 100644 index 87f51d46f3..0000000000 --- a/spec/ruby/library/net-http/httpheader/shared/set_range.rb +++ /dev/null @@ -1,89 +0,0 @@ -describe :net_httpheader_set_range, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - describe "when passed nil" do - it "returns nil" do - @headers.send(@method, nil).should be_nil - end - - it "deletes the 'Range' header entry" do - @headers["Range"] = "bytes 0-499/1234" - @headers.send(@method, nil) - @headers["Range"].should be_nil - end - end - - describe "when passed Numeric" do - it "sets the 'Range' header entry based on the passed Numeric" do - @headers.send(@method, 10) - @headers["Range"].should == "bytes=0-9" - - @headers.send(@method, -10) - @headers["Range"].should == "bytes=-10" - - @headers.send(@method, 10.9) - @headers["Range"].should == "bytes=0-9" - end - end - - describe "when passed Range" do - it "sets the 'Range' header entry based on the passed Range" do - @headers.send(@method, 10..200) - @headers["Range"].should == "bytes=10-200" - - @headers.send(@method, 1..5) - @headers["Range"].should == "bytes=1-5" - - @headers.send(@method, 1...5) - @headers["Range"].should == "bytes=1-4" - - @headers.send(@method, 234..567) - @headers["Range"].should == "bytes=234-567" - - @headers.send(@method, -5..-1) - @headers["Range"].should == "bytes=-5" - - @headers.send(@method, 1..-1) - @headers["Range"].should == "bytes=1-" - end - - it "raises a Net::HTTPHeaderSyntaxError when the first Range element is negative" do - -> { @headers.send(@method, -10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "raises a Net::HTTPHeaderSyntaxError when the last Range element is negative" do - -> { @headers.send(@method, 10..-5) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "raises a Net::HTTPHeaderSyntaxError when the last Range element is smaller than the first" do - -> { @headers.send(@method, 10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - end - - describe "when passed start, end" do - it "sets the 'Range' header entry based on the passed start and length values" do - @headers.send(@method, 10, 200) - @headers["Range"].should == "bytes=10-209" - - @headers.send(@method, 1, 5) - @headers["Range"].should == "bytes=1-5" - - @headers.send(@method, 234, 567) - @headers["Range"].should == "bytes=234-800" - end - - it "raises a Net::HTTPHeaderSyntaxError when start is negative" do - -> { @headers.send(@method, -10, 5) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "raises a Net::HTTPHeaderSyntaxError when start + length is negative" do - -> { @headers.send(@method, 10, -15) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "raises a Net::HTTPHeaderSyntaxError when length is negative" do - -> { @headers.send(@method, 10, -4) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - end -end diff --git a/spec/ruby/library/net-http/httpheader/shared/size.rb b/spec/ruby/library/net-http/httpheader/shared/size.rb deleted file mode 100644 index e2b1e4c22b..0000000000 --- a/spec/ruby/library/net-http/httpheader/shared/size.rb +++ /dev/null @@ -1,18 +0,0 @@ -describe :net_httpheader_size, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns the number of header entries in self" do - @headers.send(@method).should eql(0) - - @headers["a"] = "b" - @headers.send(@method).should eql(1) - - @headers["b"] = "b" - @headers.send(@method).should eql(2) - - @headers["c"] = "c" - @headers.send(@method).should eql(3) - end -end diff --git a/spec/ruby/library/net-http/httpheader/size_spec.rb b/spec/ruby/library/net-http/httpheader/size_spec.rb index 210060ce21..f84a0fb5ab 100644 --- a/spec/ruby/library/net-http/httpheader/size_spec.rb +++ b/spec/ruby/library/net-http/httpheader/size_spec.rb @@ -1,8 +1,22 @@ require_relative '../../../spec_helper' require 'net/http' require_relative 'fixtures/classes' -require_relative 'shared/size' describe "Net::HTTPHeader#size" do - it_behaves_like :net_httpheader_size, :size + before :each do + @headers = NetHTTPHeaderSpecs::Example.new + end + + it "returns the number of header entries in self" do + @headers.size.should.eql?(0) + + @headers["a"] = "b" + @headers.size.should.eql?(1) + + @headers["b"] = "b" + @headers.size.should.eql?(2) + + @headers["c"] = "c" + @headers.size.should.eql?(3) + end end diff --git a/spec/ruby/library/net-http/httpheader/sub_type_spec.rb b/spec/ruby/library/net-http/httpheader/sub_type_spec.rb index b39b57fe8d..9e7d2a5368 100644 --- a/spec/ruby/library/net-http/httpheader/sub_type_spec.rb +++ b/spec/ruby/library/net-http/httpheader/sub_type_spec.rb @@ -20,13 +20,13 @@ describe "Net::HTTPHeader#sub_type" do it "returns nil if no 'sub-content-type' is set" do @headers["Content-Type"] = "text" - @headers.sub_type.should be_nil + @headers.sub_type.should == nil @headers["Content-Type"] = "text;charset=utf-8" - @headers.sub_type.should be_nil + @headers.sub_type.should == nil end it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.sub_type.should be_nil + @headers.sub_type.should == nil end end diff --git a/spec/ruby/library/net-http/httpheader/to_hash_spec.rb b/spec/ruby/library/net-http/httpheader/to_hash_spec.rb index 3cebc519a6..e245c20d4c 100644 --- a/spec/ruby/library/net-http/httpheader/to_hash_spec.rb +++ b/spec/ruby/library/net-http/httpheader/to_hash_spec.rb @@ -20,6 +20,6 @@ describe "Net::HTTPHeader#to_hash" do it "does not allow modifying the headers from the returned hash" do @headers.to_hash["my-header"] = ["test"] @headers.to_hash.should == {} - @headers.key?("my-header").should be_false + @headers.key?("my-header").should == false end end diff --git a/spec/ruby/library/net-http/httprequest/initialize_spec.rb b/spec/ruby/library/net-http/httprequest/initialize_spec.rb index d009a00ed2..1229986bef 100644 --- a/spec/ruby/library/net-http/httprequest/initialize_spec.rb +++ b/spec/ruby/library/net-http/httprequest/initialize_spec.rb @@ -21,12 +21,12 @@ describe "Net::HTTPRequest#initialize" do it "uses the REQUEST_HAS_BODY to set whether the Request has a body or not" do @req.send(:initialize, "/some/path") - @req.request_body_permitted?.should be_false + @req.request_body_permitted?.should == false end it "uses the RESPONSE_HAS_BODY to set whether the Response can have a body or not" do @req.send(:initialize, "/some/path") - @req.response_body_permitted?.should be_true + @req.response_body_permitted?.should == true end describe "when passed path" do diff --git a/spec/ruby/library/net-http/httpresponse/body_spec.rb b/spec/ruby/library/net-http/httpresponse/body_spec.rb index ddfcd834c4..5b00913687 100644 --- a/spec/ruby/library/net-http/httpresponse/body_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/body_spec.rb @@ -1,7 +1,22 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'shared/body' +require 'stringio' describe "Net::HTTPResponse#body" do - it_behaves_like :net_httpresponse_body, :body + before :each do + @res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") + @socket = Net::BufferedIO.new(StringIO.new("test body")) + end + + it "returns the read body" do + @res.reading_body(@socket, true) do + @res.body.should == "test body" + end + end + + it "returns the previously read body if called a second time" do + @res.reading_body(@socket, true) do + @res.body.should.equal?(@res.body) + end + end end diff --git a/spec/ruby/library/net-http/httpresponse/entity_spec.rb b/spec/ruby/library/net-http/httpresponse/entity_spec.rb index ca8c4b29c0..d2201db37b 100644 --- a/spec/ruby/library/net-http/httpresponse/entity_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/entity_spec.rb @@ -1,7 +1,9 @@ require_relative '../../../spec_helper' require 'net/http' -require_relative 'shared/body' describe "Net::HTTPResponse#entity" do - it_behaves_like :net_httpresponse_body, :entity + it "is an alias of Net::HTTPResponse#body" do + Net::HTTPResponse.instance_method(:entity).should == + Net::HTTPResponse.instance_method(:body) + end end diff --git a/spec/ruby/library/net-http/httpresponse/error_spec.rb b/spec/ruby/library/net-http/httpresponse/error_spec.rb index 6ced90fa23..e194df95af 100644 --- a/spec/ruby/library/net-http/httpresponse/error_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/error_spec.rb @@ -4,21 +4,21 @@ require 'net/http' describe "Net::HTTPResponse#error!" do it "raises self's class 'EXCEPTION_TYPE' Exception" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - -> { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should.raise(Net::HTTPError) res = Net::HTTPInformation.new("1.0", "1xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should.raise(Net::HTTPError) res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should.raise(Net::HTTPError) res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPRetriableError) + -> { res.error! }.should.raise(Net::HTTPRetriableError) res = Net::HTTPClientError.new("1.0", "4xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPClientException) + -> { res.error! }.should.raise(Net::HTTPClientException) res = Net::HTTPServerError.new("1.0", "5xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPFatalError) + -> { res.error! }.should.raise(Net::HTTPFatalError) end end diff --git a/spec/ruby/library/net-http/httpresponse/header_spec.rb b/spec/ruby/library/net-http/httpresponse/header_spec.rb index a403dbd2c3..3ddadfb8e4 100644 --- a/spec/ruby/library/net-http/httpresponse/header_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/header_spec.rb @@ -4,6 +4,6 @@ require 'net/http' describe "Net::HTTPResponse#header" do it "returns self" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) + res.response.should.equal?(res) end end diff --git a/spec/ruby/library/net-http/httpresponse/read_body_spec.rb b/spec/ruby/library/net-http/httpresponse/read_body_spec.rb index 4530a26bfc..d8b2418624 100644 --- a/spec/ruby/library/net-http/httpresponse/read_body_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/read_body_spec.rb @@ -17,7 +17,7 @@ describe "Net::HTTPResponse#read_body" do it "returns the previously read body if called a second time" do @res.reading_body(@socket, true) do - @res.read_body.should equal(@res.read_body) + @res.read_body.should.equal?(@res.read_body) end end end @@ -34,14 +34,14 @@ describe "Net::HTTPResponse#read_body" do it "returns the passed buffer" do @res.reading_body(@socket, true) do buffer = +"" - @res.read_body(buffer).should equal(buffer) + @res.read_body(buffer).should.equal?(buffer) end end it "raises an IOError if called a second time" do @res.reading_body(@socket, true) do @res.read_body(+"") - -> { @res.read_body(+"") }.should raise_error(IOError) + -> { @res.read_body(+"") }.should.raise(IOError) end end end @@ -57,21 +57,21 @@ describe "Net::HTTPResponse#read_body" do buffer << body end - yielded.should be_true + yielded.should == true buffer.should == "test body" end end it "returns the ReadAdapter" do @res.reading_body(@socket, true) do - @res.read_body { nil }.should be_kind_of(Net::ReadAdapter) + @res.read_body { nil }.should.is_a?(Net::ReadAdapter) end end it "raises an IOError if called a second time" do @res.reading_body(@socket, true) do @res.read_body {} - -> { @res.read_body {} }.should raise_error(IOError) + -> { @res.read_body {} }.should.raise(IOError) end end end @@ -79,7 +79,7 @@ describe "Net::HTTPResponse#read_body" do describe "when passed buffer and block" do it "raises an ArgumentError" do @res.reading_body(@socket, true) do - -> { @res.read_body(+"") {} }.should raise_error(ArgumentError) + -> { @res.read_body(+"") {} }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/library/net-http/httpresponse/read_header_spec.rb b/spec/ruby/library/net-http/httpresponse/read_header_spec.rb index 3ea4ee834b..70ce988502 100644 --- a/spec/ruby/library/net-http/httpresponse/read_header_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/read_header_spec.rb @@ -4,6 +4,6 @@ require 'net/http' describe "Net::HTTPResponse#read_header" do it "returns self" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) + res.response.should.equal?(res) end end diff --git a/spec/ruby/library/net-http/httpresponse/read_new_spec.rb b/spec/ruby/library/net-http/httpresponse/read_new_spec.rb index 82f7a47ce8..3795e29d83 100644 --- a/spec/ruby/library/net-http/httpresponse/read_new_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/read_new_spec.rb @@ -12,7 +12,7 @@ test-body EOS response = Net::HTTPResponse.read_new(socket) - response.should be_kind_of(Net::HTTPOK) + response.should.is_a?(Net::HTTPOK) response.code.should == "200" response["Content-Type"].should == "text/html; charset=utf-8" diff --git a/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb b/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb index 637a2806f8..a3671d6eb5 100644 --- a/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb @@ -22,7 +22,7 @@ describe "Net::HTTPResponse#reading_body" do yielded = true end - yielded.should be_true + yielded.should == true end describe "but the response type is not allowed to have a body" do @@ -31,28 +31,28 @@ describe "Net::HTTPResponse#reading_body" do end it "returns nil" do - @res.reading_body(@socket, false) {}.should be_nil - @res.body.should be_nil + @res.reading_body(@socket, false) {}.should == nil + @res.body.should == nil end it "yields the passed block" do yielded = false @res.reading_body(@socket, true) { yielded = true } - yielded.should be_true + yielded.should == true end end end describe "when body_allowed is false" do it "returns nil" do - @res.reading_body(@socket, false) {}.should be_nil - @res.body.should be_nil + @res.reading_body(@socket, false) {}.should == nil + @res.body.should == nil end it "yields the passed block" do yielded = false @res.reading_body(@socket, true) { yielded = true } - yielded.should be_true + yielded.should == true end end end diff --git a/spec/ruby/library/net-http/httpresponse/response_spec.rb b/spec/ruby/library/net-http/httpresponse/response_spec.rb index caa0ca2d19..440c33c168 100644 --- a/spec/ruby/library/net-http/httpresponse/response_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/response_spec.rb @@ -4,6 +4,6 @@ require 'net/http' describe "Net::HTTPResponse#response" do it "returns self" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) + res.response.should.equal?(res) end end diff --git a/spec/ruby/library/net-http/httpresponse/shared/body.rb b/spec/ruby/library/net-http/httpresponse/shared/body.rb deleted file mode 100644 index 618e3936fb..0000000000 --- a/spec/ruby/library/net-http/httpresponse/shared/body.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'stringio' - -describe :net_httpresponse_body, shared: true do - before :each do - @res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - @socket = Net::BufferedIO.new(StringIO.new("test body")) - end - - it "returns the read body" do - @res.reading_body(@socket, true) do - @res.send(@method).should == "test body" - end - end - - it "returns the previously read body if called a second time" do - @res.reading_body(@socket, true) do - @res.send(@method).should equal(@res.send(@method)) - end - end -end diff --git a/spec/ruby/library/net-http/httpresponse/value_spec.rb b/spec/ruby/library/net-http/httpresponse/value_spec.rb index 2df8beaa10..e32d37500a 100644 --- a/spec/ruby/library/net-http/httpresponse/value_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/value_spec.rb @@ -4,21 +4,21 @@ require 'net/http' describe "Net::HTTPResponse#value" do it "raises an HTTP error for non 2xx HTTP Responses" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - -> { res.value }.should raise_error(Net::HTTPError) + -> { res.value }.should.raise(Net::HTTPError) res = Net::HTTPInformation.new("1.0", "1xx", "test response") - -> { res.value }.should raise_error(Net::HTTPError) + -> { res.value }.should.raise(Net::HTTPError) res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - -> { res.value }.should_not raise_error(Net::HTTPError) + -> { res.value }.should_not.raise(Net::HTTPError) res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - -> { res.value }.should raise_error(Net::HTTPRetriableError) + -> { res.value }.should.raise(Net::HTTPRetriableError) res = Net::HTTPClientError.new("1.0", "4xx", "test response") - -> { res.value }.should raise_error(Net::HTTPClientException) + -> { res.value }.should.raise(Net::HTTPClientException) res = Net::HTTPServerError.new("1.0", "5xx", "test response") - -> { res.value }.should raise_error(Net::HTTPFatalError) + -> { res.value }.should.raise(Net::HTTPFatalError) end end |
