required_envs.rb 583 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.configure do |config|
  3. config.around(:each, :required_envs) do |example|
  4. example.metadata[:required_envs].each do |secret|
  5. if ENV[secret].blank?
  6. raise "This test requires the ENV variables [#{example.metadata[:required_envs].join(', ')}], but #{secret} was not found."
  7. end
  8. end
  9. VCR.configure do |c|
  10. example.metadata[:required_envs].each do |env_key|
  11. c.filter_sensitive_data("<#{env_key}>") { ENV[env_key] }
  12. end
  13. end
  14. example.run
  15. end
  16. end