Sha256: 754468795cdd79fdb290c2c362067d8cbc1810a8a66c779d81deb5f2e3bc680d

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require "stringio"

RSpec.describe "Slices / Slice configuration", :app_integration do
  specify "Slices receive a copy of the app configuration, and can make distinct modifications" do
    with_tmp_directory(Dir.mktmpdir) do
      write "config/app.rb", <<~RUBY
        require "hanami"

        module TestApp
          class App < Hanami::App
            config.logger.stream = StringIO.new

            config.no_auto_register_paths = ["structs"]
          end
        end
      RUBY

      write "config/slices/main.rb", <<~'RUBY'
        module Main
          class Slice < Hanami::Slice
            config.no_auto_register_paths << "schemas"
          end
        end
      RUBY

      write "config/slices/search.rb", <<~'RUBY'
        module Search
          class Slice < Hanami::Slice
          end
        end
      RUBY

      require "hanami/prepare"

      expect(TestApp::App.config.no_auto_register_paths).to eq %w[structs]
      expect(Main::Slice.config.no_auto_register_paths).to eq %w[structs schemas]
      expect(Search::Slice.config.no_auto_register_paths).to eq %w[structs]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/integration/slices/slice_configuration_spec.rb
hanami-2.2.0 spec/integration/slices/slice_configuration_spec.rb
hanami-2.2.0.rc1 spec/integration/slices/slice_configuration_spec.rb
hanami-2.2.0.beta2 spec/integration/slices/slice_configuration_spec.rb
hanami-2.2.0.beta1 spec/integration/slices/slice_configuration_spec.rb