Sha256: 7117a472c213240f6caf57ebe512cc6f276590b02c235e2a580c0e45228f3fcf

Contents?: true

Size: 1.66 KB

Versions: 49

Compression:

Stored size: 1.66 KB

Contents

require File.expand_path('../../../../../spec_helper', __FILE__)
require 'net/http'
require File.expand_path('../fixtures/classes', __FILE__)

describe "Net::HTTPHeader#content_length" do
  before(:each) do
    @headers = NetHTTPHeaderSpecs::Example.new
  end

  it "returns nil if no 'Content-Length' header entry is set" do
    @headers.content_length.should be_nil
  end

  it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Length' header entry has an invalid format" do
    @headers["Content-Length"] = "invalid"
    lambda { @headers.content_length }.should raise_error(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"] = "123valid"
    @headers.content_length.should eql(123)

    @headers["Content-Length"] = "valid123"
    @headers.content_length.should eql(123)
  end
end

describe "Net::HTTPHeader#content_length=" do
  before(:each) do
    @headers = NetHTTPHeaderSpecs::Example.new
  end

  it "removes the 'Content-Length' entry if passed false or nil" do
    @headers["Content-Length"] = "123"
    @headers.content_length = nil
    @headers["Content-Lenght"].should be_nil
  end

  it "sets the 'Content-Length' entry to the passed value" do
    @headers.content_length = "123"
    @headers["Content-Length"].should == "123"

    @headers.content_length = "123valid"
    @headers["Content-Length"].should == "123"
  end

  it "sets the 'Content-Length' entry to 0 if the passed value is not valid" do
    @headers.content_length = "invalid123"
    @headers["Content-Length"].should == "0"
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-7.5.1 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-7.4.1 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-7.1.17 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-6.2.0 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-6.0.11 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-5.5.18 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-5.5.17 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-5.5.15 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-5.5.2 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-5.5.0 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-3.3.5 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb
rhodes-3.4.2 spec/framework_spec/app/spec/library/net/http/httpheader/content_length_spec.rb