vendor/rack/test/spec_rack_utils.rb in relevance-castronaut-0.5.4 vs vendor/rack/test/spec_rack_utils.rb in relevance-castronaut-0.6.0

- old
+ new

@@ -63,31 +63,33 @@ helper.call(%w(foo bar baz identity), [["*", 0], ["identity", 0.1]]).should.equal("identity") end end context "Rack::Utils::HeaderHash" do - specify "should capitalize on all accesses" do - h = Rack::Utils::HeaderHash.new("foo" => "bar") - h["foo"].should.equal "bar" - h["Foo"].should.equal "bar" - h["FOO"].should.equal "bar" + specify "should retain header case" do + h = Rack::Utils::HeaderHash.new("Content-MD5" => "d5ff4e2a0 ...") + h['ETag'] = 'Boo!' + h.to_hash.should.equal "Content-MD5" => "d5ff4e2a0 ...", "ETag" => 'Boo!' + end - h.to_hash.should.equal "Foo" => "bar" + specify "should check existence of keys case insensitively" do + h = Rack::Utils::HeaderHash.new("Content-MD5" => "d5ff4e2a0 ...") + h.should.include 'content-md5' + h.should.not.include 'ETag' + end - h["bar-zzle"] = "quux" - - h.to_hash.should.equal "Foo" => "bar", "Bar-Zzle" => "quux" + specify "should merge case-insensitively" do + h = Rack::Utils::HeaderHash.new("ETag" => 'HELLO', "content-length" => '123') + merged = h.merge("Etag" => 'WORLD', 'Content-Length' => '321', "Foo" => 'BAR') + merged.should.equal "Etag"=>'WORLD', "Content-Length"=>'321', "Foo"=>'BAR' end - specify "should capitalize correctly" do - h = Rack::Utils::HeaderHash.new - - h.capitalize("foo").should.equal "Foo" - h.capitalize("foo-bar").should.equal "Foo-Bar" - h.capitalize("foo_bar").should.equal "Foo_Bar" - h.capitalize("foo bar").should.equal "Foo Bar" - h.capitalize("foo-bar-quux").should.equal "Foo-Bar-Quux" - h.capitalize("foo-bar-2quux").should.equal "Foo-Bar-2quux" + specify "should overwrite case insensitively and assume the new key's case" do + h = Rack::Utils::HeaderHash.new("Foo-Bar" => "baz") + h["foo-bar"] = "bizzle" + h["FOO-BAR"].should.equal "bizzle" + h.length.should.equal 1 + h.to_hash.should.equal "foo-bar" => "bizzle" end specify "should be converted to real Hash" do h = Rack::Utils::HeaderHash.new("foo" => "bar") h.to_hash.should.be.instance_of Hash