Sha256: 3598fc43b77ad79047348a8645eabe7905e0bee581f1c521e19ad93a39e3a342

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require "hanami"

RSpec.describe "App view / Configuration", :app_integration do
  before do
    module TestApp
      class App < Hanami::App
        config.root = "/test_app"
      end
    end

    Hanami.app.instance_eval(&app_hook) if respond_to?(:app_hook)
    Hanami.app.register_slice :main
    Hanami.app.prepare

    module TestApp
      class View < Hanami::View
      end
    end
  end

  let(:view_class) { TestApp::View }

  subject(:config) { view_class.config }

  it "applies default view configuration from the app" do
    aggregate_failures do
      expect(config.layouts_dir).to eq "layouts"
      expect(config.layout).to eq "app"
    end
  end

  context "custom views configuration on app" do
    let(:app_hook) {
      proc do
        config.views.layouts_dir = "custom_layouts"
        config.views.layout = "my_layout"
      end
    }

    it "applies the custom configuration" do
      aggregate_failures do
        expect(config.layouts_dir).to eq "custom_layouts"
        expect(config.layout).to eq "my_layout"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-2.0.0.beta1.1 spec/new_integration/view/configuration_spec.rb
hanami-2.0.0.beta1 spec/new_integration/view/configuration_spec.rb