summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorAdam Niedzielski <adamsunday@gmail.com>2017-01-09 18:19:48 +0100
committerAdam Niedzielski <adamsunday@gmail.com>2017-01-09 18:19:48 +0100
commita8177e03e5eeade5b8af405dbb4bcd8a6d06bb0a (patch)
tree02539d1a9f940d1f21f94d4a4b530250037c404f /spec/support
parent583deef209af5a2700701fb0933582a7b5680620 (diff)
downloadgitlab-ce-a8177e03e5eeade5b8af405dbb4bcd8a6d06bb0a.tar.gz
Introduce "stub_env" test helper for safely stubbing environment variables
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/stub_env.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/support/stub_env.rb b/spec/support/stub_env.rb
new file mode 100644
index 00000000000..18597b5c71f
--- /dev/null
+++ b/spec/support/stub_env.rb
@@ -0,0 +1,7 @@
+module StubENV
+ def stub_env(key, value)
+ allow(ENV).to receive(:[]).and_call_original unless @env_already_stubbed
+ @env_already_stubbed ||= true
+ allow(ENV).to receive(:[]).with(key).and_return(value)
+ end
+end