IOError: closed stream on Ruby/Rails Test



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 ='pdf') << response.body.force_encoding('UTF-8')
  reader ='') # this is line that throws the closed stream error

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.