forked from rack/rack-contrib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
spec_rack_etag.rb
23 lines (20 loc) · 834 Bytes
/
spec_rack_etag.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'test/spec'
require 'rack/mock'
require 'rack/contrib/etag'
context "Rack::ETag" do
specify "sets ETag if none is set" do
app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "Hello, World!"] }
response = Rack::ETag.new(app).call({})
response[1]['ETag'].should.equal "\"65a8e27d8879283831b664bd8b7f0ad4\""
end
specify "does not change ETag if it is already set" do
app = lambda { |env| [200, {'Content-Type' => 'text/plain', 'ETag' => '"abc"'}, "Hello, World!"] }
response = Rack::ETag.new(app).call({})
response[1]['ETag'].should.equal "\"abc\""
end
specify "does not set ETag if steaming body" do
app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello", "World"]] }
response = Rack::ETag.new(app).call({})
response[1]['ETag'].should.equal nil
end
end