Topic: Checking the file content from send_file
I am test-driving a controller that sends back something other than a page template--in this case, PDF. I'd like to check the content coming back. This is what I've done; does anyone have any suggestions for how I could improve it? Has someone written something in a library I could have used? Is there a way I can do this that is less tightly coupled to the current implementation of send_file?
output_collector = Struct.new(:content).new
self.content = "" if self.content.nil?
self.content << bytes
I use it this way:
post :whatever, ...
assert_equal(File.open("goldenmaster.pdf", "rb").read, byte_content_of(@response)
Thanks for your help.
Last edited by jbrains (2006-11-23 19:15:10)