This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.
Last Updated: 2023-03-28
I wanted my tests to take a special action when running on my CI server. Seeing that they set the env variable 'CI' to 'true' I wrote the following code:
continuous_integration_env = ENV['CI'] if Rails.env.production? || (Rails.env.test? && continuous_integration_env == true) run_me end
This, of course, didn't work. Why? Because "true" != true
Webpacker::Compiler.env['FORCE_COOKIE_NOTICE'] = true
ActionView::Template::Error (no implicit conversion of true into String):
The issue again was that a string was expected as an env variable. An example fix:
Webpacker::Compiler.env['FORCE_COOKIE_NOTICE'] = "true"
Always treat ENV variables as simple strings, no matter what.