IOError: closed stream on Ruby/Rails Test

rails

#1

Trying to read a PDF in an integration test. This was working fine using the circleci/ruby:2.4.1-node image, but upon upgrading to ruby 2.6.0 and the circleci/ruby:2.6.0-node-browsers image, I get the following error:

IOError: closed stream

This points to a method in my test_helper file:

def read_pdf_from_response(response)
  temp_pdf = Tempfile.new('pdf') << response.body.force_encoding('UTF-8')
  reader = PDF::Reader.new(temp_pdf)
  reader.pages.map(&:text).join('') # this is line that throws the closed stream error
end

Any ideas here on how to troubleshoot? This all works fine locally, just not on circleci. And it worked fine before I upgraded to ruby 2.6.

Thanks