RSpec - Allow any instance of ENV to receive

1.1k Views Asked by At

I'm testing controller with view overwritten with deface (no DSL) and I have a problem...

In deface file I'm fetching parameter from ENV and because of that my tests are failing.

Deface file:

if ENV.fetch('something', nil).present?
  Deface::Override.new(...)
end

Rspec:

allow(ENV).to receive(:fetch).with("something").and_return('value')

Question: How can I set value globally so ENV will be available in deface file ?

Note: allow_any_instance_of doesn't work for ENV.

0

There are 0 best solutions below