Sha256: 9e766b7d5fcc52189cef650837f6449badf01305138d3a09225c62ffbff64889

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

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

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

  it "returns a Hash representing all Header entries (keys in lower case, values as arrays)" do
    @headers.to_hash.should == {}

    @headers["My-Header"] = "test"
    @headers.to_hash.should == { "my-header" => ["test"] }

    @headers.add_field("My-Header", "another test")
    @headers.to_hash.should == { "my-header" => ["test", "another test"] }
  end

  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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysl-net-http-1.0.1 spec/httpheader/to_hash_spec.rb
rubysl-net-http-2.0.4 spec/httpheader/to_hash_spec.rb
rubysl-net-http-1.0.0 spec/httpheader/to_hash_spec.rb