You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I would like to share with you something that is happening to me when I try to set an environment variable through .env.test file for testing purpose.
I have a file ".env" with the following code:
SOME_KEY_API="ENV_KEY"
and as I want to test some behavior I've created the file ".env.test" with the following code:
SOME_KEY_API="TEST_KEY"
and as it says the README file: "Variables defined in .env. will override any values set in .env or already defined in the environment."
so when check the environment while I'm testing, Rails.env is test, but when I check my ENV, SOME_KEY_API still is ENV_KEY. I was debugging the flow of the info through the gem and I was able to see that in the last iteration, in this part of the code:
"dotenv-2.0.1/lib/dotenv.rb"
# Internal: Helper to expand list of filenames.
#
# Returns a hash of all the loaded environment variables.
def with(*filenames, &block)
filenames << ".env" if filenames.empty?
filenames.reduce({}) do |hash, filename|
hash.merge! block.call(File.expand_path(filename)) || {}
end
end
"hash" has my SOME_KEY_API="TEST_KEY" and when the "merge" is applied is replacing "TEST_KEY" with "ENV_KEY". So finally for testing environment I never get the "TEST_KEY".
Could you check this behavior? and please tell me if you need more info about it.
The text was updated successfully, but these errors were encountered:
Hello. I would like to share with you something that is happening to me when I try to set an environment variable through .env.test file for testing purpose.
I have a file ".env" with the following code:
and as I want to test some behavior I've created the file ".env.test" with the following code:
and as it says the README file: "Variables defined in .env. will override any values set in .env or already defined in the environment."
so when check the environment while I'm testing, Rails.env is test, but when I check my ENV, SOME_KEY_API still is ENV_KEY. I was debugging the flow of the info through the gem and I was able to see that in the last iteration, in this part of the code:
"dotenv-2.0.1/lib/dotenv.rb"
"hash" has my SOME_KEY_API="TEST_KEY" and when the "merge" is applied is replacing "TEST_KEY" with "ENV_KEY". So finally for testing environment I never get the "TEST_KEY".
Could you check this behavior? and please tell me if you need more info about it.
The text was updated successfully, but these errors were encountered: