rspec How to test the `require`

430 Views Asked by At

I have a model that broke my application on Hereku. I read the logs and I saw that I needed to require 'zip' Now I am not sure why it worked on my local or on CI but I would like to write a test that would make sure that require 'zip' in on that model

my model is really simple

class File < ApplicationRecord
  require 'zip' # this is the line I am not sure how to test

  has_one_attached :zip_file
end

Thanks for all the help

1

There are 1 best solutions below

1
taylorthurlow On

kernel#require returns true when the library is loaded successfully, and false when the library is already loaded. Perhaps that could be useful in testing the call.

That said, I don't think this is something that you should be testing directly. Your real "issue" is figuring out why the require is necessary on Heroku, and to go from there. I would leave the require in the code and start looking through Heroku's documentation.