# frozen_string_literal: true require "hanami/utils/string" RSpec.shared_examples "a new app" do let(:app) { Hanami::Utils::String.new(input).underscore.to_s } it "generates vanilla app" do project = "bookshelf_generate_app_#{Random.rand(100_000_000)}" with_project(project) do app_name = Hanami::Utils::String.new(app).classify app_upcase = Hanami::Utils::String.new(app).upcase output = <<-OUT create apps/#{app}/application.rb create apps/#{app}/config/routes.rb create apps/#{app}/views/application_layout.rb create apps/#{app}/templates/application.html.erb create apps/#{app}/assets/favicon.ico create apps/#{app}/controllers/.gitkeep create apps/#{app}/assets/images/.gitkeep create apps/#{app}/assets/javascripts/.gitkeep create apps/#{app}/assets/stylesheets/.gitkeep create spec/#{app}/features/.gitkeep create spec/#{app}/controllers/.gitkeep create spec/#{app}/views/application_layout_spec.rb insert config/environment.rb insert config/environment.rb append .env.development append .env.test OUT run_cmd "hanami generate app #{input}", output # # apps//application.rb # expect("apps/#{app}/application.rb").to have_file_content <<-END require 'hanami/helpers' require 'hanami/assets' module #{app_name} class App < Hanami::App configure do ## # BASIC # # Define the root path of this application. # All paths specified in this configuration are relative to path below. # root __dir__ # Relative load paths where this application will recursively load the # code. # # When you add new directories, remember to add them here. # load_paths << [ 'controllers', 'views' ] # Handle exceptions with HTTP statuses (true) or don't catch them (false). # Defaults to true. # See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management # # handle_exceptions true ## # HTTP # # Routes definitions for this application # See: http://www.rubydoc.info/gems/hanami-router#Usage # routes 'config/routes' # URI scheme used by the routing system to generate absolute URLs # Defaults to "http" # # scheme 'https' # URI host used by the routing system to generate absolute URLs # Defaults to "localhost" # # host 'example.org' # URI port used by the routing system to generate absolute URLs # Argument: An object coercible to integer, defaults to 80 if the scheme # is http and 443 if it's https # # This should only be configured if app listens to non-standard ports # # port 443 # Enable cookies # Argument: boolean to toggle the feature # A Hash with options # # Options: # :domain - The domain (String - nil by default, not required) # :path - Restrict cookies to a relative URI # (String - nil by default) # :max_age - Cookies expiration expressed in seconds # (Integer - nil by default) # :secure - Restrict cookies to secure connections # (Boolean - Automatically true when using HTTPS) # See #scheme and #ssl? # :httponly - Prevent JavaScript access (Boolean - true by default) # # cookies true # or # cookies max_age: 300 # Enable sessions # Argument: Symbol the Rack session adapter # A Hash with options # # See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie # # sessions :cookie, secret: ENV['#{app_upcase}_SESSIONS_SECRET'] # Configure Rack middleware for this application # # middleware.use Rack::Protection # Default format for the requests that don't specify an HTTP_ACCEPT header # Argument: A symbol representation of a mime type, defaults to :html # # default_request_format :html # Default format for responses that don't consider the request format # Argument: A symbol representation of a mime type, defaults to :html # # default_response_format :html ## # TEMPLATES # # The layout to be used by all views # layout :application # It will load #{app_name}::Views::ApplicationLayout # The relative path to templates # templates 'templates' ## # ASSETS # assets do # JavaScript compressor # # Supported engines: # # * :builtin # * :uglifier # * :yui # * :closure # # See: https://guides.hanamirb.org/assets/compressors # # In order to skip JavaScript compression comment the following line javascript_compressor :builtin # Stylesheet compressor # # Supported engines: # # * :builtin # * :yui # * :sass # # See: https://guides.hanamirb.org/assets/compressors # # In order to skip stylesheet compression comment the following line stylesheet_compressor :builtin # Specify sources for assets # sources << [ 'assets' ] end ## # SECURITY # # X-Frame-Options is a HTTP header supported by modern browsers. # It determines if a web page can or cannot be included via and #