How to retrieve response headers in integration tests?


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
# …




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.