# frozen_string_literal: true RSpec.describe "App view / Helpers / User-defined helpers / Scope helpers", :app_integration do before do with_directory(make_tmp_directory) do write "config/app.rb", <<~RUBY module TestApp class App < Hanami::App end end RUBY write "app/view.rb", <<~RUBY # auto_register: false require "hanami/view" module TestApp class View < Hanami::View config.layout = nil end end RUBY write "app/views/helpers.rb", <<~'RUBY' # auto_register: false module TestApp module Views module Helpers def exclaim_from_app(str) tag.h1("#{str}! (app helper)") end end end end RUBY before_prepare if respond_to?(:before_prepare) require "hanami/prepare" end end describe "app view" do def before_prepare write "app/views/posts/show.rb", <<~RUBY module TestApp module Views module Posts class Show < TestApp::View end end end end RUBY write "app/templates/posts/show.html.erb", <<~ERB <%= exclaim_from_app("Hello world") %> ERB end it "makes user-defined helpers available in templates" do output = TestApp::App["views.posts.show"].call.to_s.strip expect(output).to eq "