# How to retrieve response headers in integration tests?

**URL:** <https://www.ruby-forum.com/t/how-to-retrieve-response-headers-in-integration-tests/110588>\
**Category:** Rails\
**Created:** [July 27, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/how-to-retrieve-response-headers-in-integration-tests/110588 "2007-07-27T21:00:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![atraeyu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@atraeyu](https://www.ruby-forum.com/u/atraeyu)\
**Post date:** [July 27, 2007, 9:00pm UTC](https://www.ruby-forum.com/t/how-to-retrieve-response-headers-in-integration-tests/110588/1 "2007-07-27T21:00:40Z")

</div>

With the code below, the output is “Date is: []”. Why? If I start the  
server and `curl` the URL, I get headers that include Last-Modified,  
yet I cannot retreive them from within the integration tests. What am  
I doing wrong?

require File.dirname( **FILE** ) + ‘/…/test\_helper’  
class CacheTest \< ActionController::IntegrationTest  
def test\_caching  
get “/repos/#{@repos}/revisions”  
assert\_response 200  
date = headers[‘Last-Modified’]  
puts 'Date is: ’ + date.inspect  
# …  
end  
end

Thanks

n

---

<div class="post-metadata">

**Author:** ![atraeyu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b19c9b/32.png) [@atraeyu](https://www.ruby-forum.com/u/atraeyu)\
**Post date:** [July 28, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/how-to-retrieve-response-headers-in-integration-tests/110588/2 "2007-07-28T23:17:09Z")

</div>

Okay, so the AWDR book was mistaken (p212) in that the ‘headers’  
accessor does not give you useful information from the last response  
in the integration test. Instead, using ‘response.headers’ gave me  
what I was expecting.

n
