Why isn't HANAMI_ENV hard set to test in spec_hepler?

the spec_helper.rb in a generated app looks like this:

# frozen_string_literal: true

require "pathname"
SPEC_ROOT = Pathname(__dir__).realpath.freeze

ENV["HANAMI_ENV"] ||= "test"
require "hanami/prepare"

require_relative "support/rspec"
require_relative "support/requests"

HANAMI_ENV is set with ||=. This could be dangerous for users who executes tests in i.a. a docker-container, where HANAMI_ENV is set at compose-time to development.

Why not setting HANAMI_ENV to test:

ENV["HANAMI_ENV"] = "test"

Or are there scenarios, where tests should be executed in antother HANAMI_ENV?


@wuarmin Because that policy will guarantee flexibility to end users.

In short: we don’t know how engineers are going to use Hanami. In cases like this we give the freedom to override the defaults.

1 Like

Ok, thanks for the reply.

1 Like