spec/ramaze/dispatcher/file.rb in ramaze-0.3.0 vs spec/ramaze/dispatcher/file.rb in ramaze-0.3.5
- old
+ new
@@ -19,6 +19,37 @@
else
original = File.read(file)
end
get('/favicon.ico').body.should == original
end
+
+ it 'should send ETag' do
+ res = get '/test_download.css'
+ res.headers['ETag'].should.not.be == nil
+ res.headers['ETag'].length.should == 34 # "32 hash"
+ end
+
+ it 'should send Last-Modified' do
+ res = get '/test_download.css'
+ res.headers['Last-Modified'].should.not.be == nil
+ res.headers['Last-Modified'].should == File.stat(@public_root/'test_download.css').mtime.httpdate
+ end
+
+ it 'should respect ETag with IF_NONE_MATCHES' do
+ res = get '/test_download.css'
+ etag = res.headers['ETag']
+ etag.should.not.be == nil
+ res = get '/test_download.css', :if_none_match=>etag
+ res.status.should == 304
+ res.body.should == ''
+ end
+
+ it 'should respect If-Modified' do
+ res = get '/test_download.css'
+ mtime = res.headers['Last-Modified']
+ mtime.should.not.be == nil
+ res = get '/test_download.css', :if_modified_since=>mtime
+ res.status.should == 304
+ res.body.should == ''
+ end
+
end