Sha256: 0af014c6926732f069d2a9631ead7d81afa518edad403142bfd19e342d355fda

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require "hanami"

RSpec.describe "App view / Path", :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(:paths) { view_class.config.paths }

  context "default path" do
    it "is 'templates' appended to the slice's root path" do
      expect(paths.map { |path| path.dir.to_s }).to eq ["/test_app/app/templates"]
    end
  end

  context "relative path provided in app config" do
    let(:app_hook) {
      proc do
        config.views.paths = ["my_templates"]
      end
    }

    it "configures the path as the relative path appended to the slice's root path" do
      expect(paths.map { |path| path.dir.to_s }).to eq ["/test_app/app/my_templates"]
    end
  end

  context "absolute path provided in app config" do
    let(:app_hook) {
      proc do
        config.views.paths = ["/absolute/path"]
      end
    }

    it "leaves the absolute path in place" do
      expect(paths.map { |path| path.dir.to_s }).to eq ["/absolute/path"]
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hanami-2.0.3 spec/integration/view/path_spec.rb
hanami-2.0.2 spec/integration/view/path_spec.rb
hanami-2.0.1 spec/integration/view/path_spec.rb
hanami-2.0.0 spec/integration/view/path_spec.rb
hanami-2.0.0.rc1 spec/integration/view/path_spec.rb
hanami-2.0.0.beta4 spec/integration/view/path_spec.rb
hanami-2.0.0.beta3 spec/integration/view/path_spec.rb
hanami-2.0.0.beta2 spec/new_integration/view/path_spec.rb
hanami-2.0.0.beta1.1 spec/new_integration/view/path_spec.rb
hanami-2.0.0.beta1 spec/new_integration/view/path_spec.rb