0
У меня есть файл lib/require/environment_helpers.rb, содержащий вспомогательные методы. Существует больше методов, но он не завернут в модуль.RSpec stub environment helper
def development?
Rails.env.development?
end
def test?
Rails.env.test?
end
Я пытаюсь отключить эти методы и не повезло. Я пробовал:
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
проверки этот вопрос/ответ http://stackoverflow.com/ вопросы/21153666/mock-rails-env-development-using-rspec/21154359 и особенно эта часть кода 'receive (: env) .and_return (ActiveSupport :: StringInquirer.new (" production "))' – gotva