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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9be5d718d17f374932ae41a434174e6a?d=identicon&s=25 Nathan Fiedler (Guest)
on 2007-07-27 21: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
    # ...
  end
end

Thanks

n
9be5d718d17f374932ae41a434174e6a?d=identicon&s=25 Nathan Fiedler (Guest)
on 2007-07-28 23: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.

n
This topic is locked and can not be replied to.