summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongli Lai (Phusion) <hongli@phusion.nl>2009-06-17 17:19:19 -0500
committerJoshua Peek <josh@joshpeek.com>2009-06-17 17:19:19 -0500
commitdfab30daae0f1748c0e93009583dc33dbc838a7c (patch)
tree6bd9e9339a2bf7d1302eb32986c4a4281493a69b
parentf61f21c22caf2d784d2a0e00e4866cf528c21ced (diff)
downloadrack-dfab30daae0f1748c0e93009583dc33dbc838a7c.tar.gz
Add unit tests for Rack::Util::HeaderHash#delete. [#54 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
-rw-r--r--test/spec_rack_utils.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/spec_rack_utils.rb b/test/spec_rack_utils.rb
index 7dd5880e..d1823cd5 100644
--- a/test/spec_rack_utils.rb
+++ b/test/spec_rack_utils.rb
@@ -181,6 +181,30 @@ context "Rack::Utils::HeaderHash" do
h = Rack::Utils::HeaderHash.new("foo" => ["bar", "baz"])
h.to_hash.should.equal({ "foo" => "bar\nbaz" })
end
+
+ specify "should be able to delete the given key case-sensitively" do
+ h = Rack::Utils::HeaderHash.new("foo" => "bar")
+ h.delete("foo")
+ h["foo"].should.be.nil
+ h["FOO"].should.be.nil
+ end
+
+ specify "should be able to delete the given key case-insensitively" do
+ h = Rack::Utils::HeaderHash.new("foo" => "bar")
+ h.delete("FOO")
+ h["foo"].should.be.nil
+ h["FOO"].should.be.nil
+ end
+
+ specify "should return the deleted value when #delete is called on an existing key" do
+ h = Rack::Utils::HeaderHash.new("foo" => "bar")
+ h.delete("Foo").should.equal("bar")
+ end
+
+ specify "should return nil when #delete is called on a non-existant key" do
+ h = Rack::Utils::HeaderHash.new("foo" => "bar")
+ h.delete("Hello").should.be.nil
+ end
end
context "Rack::Utils::Context" do