Sha256: 753fe0e322266bb2b60bf7d8db36f36d7944da999d3bac68d6a4a6177e0fb14a

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

require "dry/inflector"
require "hanami/configuration"
require "hanami/slice_name"

RSpec.describe Hanami::Configuration, "#slices" do
  subject(:config) { described_class.new(app_name: app_name, env: :development) }
  let(:app_name) { Hanami::SliceName.new(double(name: "MyApp::App"), inflector: Dry::Inflector.new) }

  subject(:slices) { config.slices }

  before do
    @orig_env = ENV.to_h
  end

  after do
    ENV.replace(@orig_env)
  end

  it "is nil by default" do
    is_expected.to be nil
  end

  it "defaults to the HANAMI_LOAD_SLICES env var, separated by commas" do
    ENV["HANAMI_SLICES"] = "main,admin"
    is_expected.to eq %w[main admin]
  end

  it "strips spaces from HANAMI_LOAD_SLICES env var entries" do
    ENV["HANAMI_SLICES"] = "main, admin"
    is_expected.to eq %w[main admin]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-2.0.0.beta3 spec/unit/hanami/configuration/slices_spec.rb
hanami-2.0.0.beta2 spec/unit/hanami/configuration/slices_spec.rb