RSpec stub environment helper -
i've got lib/require/environment_helpers.rb file contains helper methods. there more methods, it's not wrapped in module.
def development? rails.env.development? end def test? rails.env.test? end
i'm trying stub these methods out , not having luck. i've tried:
before :each allow(rails.env).to receive(:production?) { false } end before :each allow(rails).to receive(:production?) { false } end before :each allow(serviceundertest).to receive(:production?) { false } end
trying stub these methods
you can stub this
before :each rails_env = double(:rails_env, development?: false) expect(rails).to receive(:env).and_return(rails_env) expect(rails_env).to receive(:development?).and_return(false) end
Comments
Post a Comment