Sha256: 02fedc3756b2069fadbfb3dd63f0fcb8c14d76dba753d005b03b6b0fc4d19912

Contents?: true

Size: 1.21 KB

Versions: 14

Compression:

Stored size: 1.21 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Typhoeus::NormalizedHeaderHash do
  before(:all) do
    @klass = Typhoeus::NormalizedHeaderHash
  end

  it "should normalize keys on assignment" do
    hash = @klass.new
    hash['Content-Type'] = 'text/html'
    hash['content-type'].should == 'text/html'
    hash[:content_type].should == 'text/html'
    hash['Accepts'] = 'text/javascript'
    hash['accepts'].should == 'text/javascript'
  end

  it "should normalize the keys on instantiation" do
    hash = @klass.new('Content-Type' => 'text/html', :x_http_header => 'foo', 'X-HTTP-USER' => 'bar')
    hash.keys.should =~ ['Content-Type', 'X-Http-Header', 'X-Http-User']
  end

  it "should merge keys correctly" do
    hash = @klass.new
    hash.merge!('Content-Type' => 'fdsa')
    hash['content-type'].should == 'fdsa'
  end

  it "should allow any casing of keys" do
    hash = @klass.new
    hash['Content-Type'] = 'fdsa'
    hash['content-type'].should == 'fdsa'
    hash['cOnTent-TYPE'].should == 'fdsa'
    hash['Content-Type'].should == 'fdsa'
  end

  it "should support has_key?" do
    hash = @klass.new
    hash['Content-Type'] = 'fdsa'
    hash.has_key?('cOntent-Type').should be_true
  end
end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
marnen-typhoeus-0.3.7 spec/typhoeus/normalized_header_hash_spec.rb
marnen-typhoeus-0.3.6 spec/typhoeus/normalized_header_hash_spec.rb
marnen-typhoeus-0.3.5 spec/typhoeus/normalized_header_hash_spec.rb
marnen-typhoeus-0.3.4 spec/typhoeus/normalized_header_hash_spec.rb
typhoeus-0.3.3 spec/typhoeus/normalized_header_hash_spec.rb
typhoeus-0.3.2 spec/typhoeus/normalized_header_hash_spec.rb
xenda-typhoeus-0.2.4 spec/typhoeus/normalized_header_hash_spec.rb
typhoeus-0.2.4 spec/typhoeus/normalized_header_hash_spec.rb
typhoeus-0.2.3 spec/typhoeus/normalized_header_hash_spec.rb
arachni-typhoeus-0.2.0.2 spec/typhoeus/normalized_header_hash_spec.rb
typhoeus-0.2.2 spec/typhoeus/normalized_header_hash_spec.rb
arachni-typhoeus-0.2.0.1 spec/typhoeus/normalized_header_hash_spec.rb
arachni-typhoeus-0.2.0 spec/typhoeus/normalized_header_hash_spec.rb
typhoeus-0.2.1 spec/typhoeus/normalized_header_hash_spec.rb