Forum: Ruby on Rails How to retrieve response headers in integration tests?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nathan F. (Guest)
on 2007-07-27 23:00
(Received via mailing list)
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
    # ...


Nathan F. (Guest)
on 2007-07-29 01:17
(Received via mailing list)
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.

This topic is locked and can not be replied to.