diff options
Diffstat (limited to 'spec/ruby/library/net-http/httpresponse')
11 files changed, 51 insertions, 54 deletions
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 |
