Setting Rails.application.config for specific spec

I recently ran into a bug where I wasn’t setting an image src correctly for an HTML image tag. The problem was that I wasn’t using the #image_path method when specifying the path to the image, but was rather just calling "assets/" + src which wouldn’t work in a production environment, because the assets get compiled and a hash value is added at the end of the compiled asset name and of course there was no asset at the "" path, because it’s actually at "{hash}.png" path.

So I fixed it and now I want to write a spec for the bug, but in order to do that i need to set config.assets.digest = true, but it’s disabled in my test environment. So my question is- Is there a way to enable this configuration setting just for one specific spec. Something like this:

scenario "image has the correct source" do
  Rails.application.config.assets.digest = true
  visit image_page
  expect(image["src"]).to match /\/assets\/image-.+\.png/
  Rails.application.config.assets.digest = false