Merge branch 'develop' into unstable
This commit is contained in:
commit
c458489d18
|
@ -1,6 +1,6 @@
|
||||||
name: ci
|
name: ci
|
||||||
|
|
||||||
on:
|
"on":
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- ".github/workflows/ci.yml"
|
- ".github/workflows/ci.yml"
|
||||||
|
@ -24,14 +24,12 @@ jobs:
|
||||||
ruby:
|
ruby:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
- "2.6"
|
- "2.6"
|
||||||
include:
|
- "2.5"
|
||||||
- ruby: "2.7"
|
- "2.4"
|
||||||
coverage: "true"
|
|
||||||
env:
|
|
||||||
COVERAGE: ${{matrix.coverage}}
|
|
||||||
CI: true
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
- name: Install package dependencies
|
||||||
|
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
|
||||||
- name: Set up Ruby
|
- name: Set up Ruby
|
||||||
uses: ruby/setup-ruby@v1
|
uses: ruby/setup-ruby@v1
|
||||||
with:
|
with:
|
||||||
|
@ -39,13 +37,7 @@ jobs:
|
||||||
- name: Install latest bundler
|
- name: Install latest bundler
|
||||||
run: |
|
run: |
|
||||||
gem install bundler --no-document
|
gem install bundler --no-document
|
||||||
bundle config set without 'tools benchmarks docs'
|
|
||||||
- name: Bundle install
|
- name: Bundle install
|
||||||
run: bundle install --jobs 4 --retry 3
|
run: bundle install --jobs 4 --retry 3
|
||||||
- name: Run all tests
|
- name: Run all tests
|
||||||
run: bundle exec rake
|
run: script/ci
|
||||||
- name: Send test coverage report to codecov.io
|
|
||||||
uses: codecov/codecov-action@v1
|
|
||||||
with:
|
|
||||||
token: ${{secrets.COVERAGE_TOKEN}}
|
|
||||||
file: ./coverage/.resultset.json
|
|
||||||
|
|
35
CHANGELOG.md
35
CHANGELOG.md
|
@ -50,6 +50,31 @@ end
|
||||||
- [Luca Guidi] Removed `shotgun` and code reloading from the core. Code reloading is implemented by `hanami-reloader` gem.
|
- [Luca Guidi] Removed `shotgun` and code reloading from the core. Code reloading is implemented by `hanami-reloader` gem.
|
||||||
- [Luca Guidi] Removed support for `.hanamirc`
|
- [Luca Guidi] Removed support for `.hanamirc`
|
||||||
|
|
||||||
|
## v1.3.3 - 2019-09-20
|
||||||
|
### Added
|
||||||
|
- [Gray Manley] Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- [Alfonso Uceda & Luca Guidi] Ensure to use `:host` option when mounting an application in main router (e.g. `mount Beta::Application.new, at: "/", host: "beta.hanami.test"`)
|
||||||
|
|
||||||
|
## v1.3.2 - 2019-07-26
|
||||||
|
### Added
|
||||||
|
- [Luca Guidi] Support both `hanami-validations` 1 and 2
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- [Wisnu Adi Nurcahyo] Ensure `hanami generate` syntax for Welcome page is compatible with ZSH
|
||||||
|
- [Luca Guidi] Don't let `hanami` to crash when called without `bundle exec`
|
||||||
|
|
||||||
|
## v1.3.1 - 2019-01-18
|
||||||
|
### Added
|
||||||
|
- [Luca Guidi] Official support for Ruby: MRI 2.6
|
||||||
|
- [Luca Guidi] Support `bundler` 2.0+
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- [Aidan Coyle] Remove from app generator support for deprecated `force_ssl` setting
|
||||||
|
- [Alessandro Caporrini] Remove from app generator support for deprecated `body_parsers` setting
|
||||||
|
- [Daphne Rouw & Sean Collins] Make app generator to work when code in `config/environment.rb` uses double quotes
|
||||||
|
|
||||||
## v1.3.0 - 2018-10-24
|
## v1.3.0 - 2018-10-24
|
||||||
### Added
|
### Added
|
||||||
- [Luca Guidi] Automatically log body payload from body parsers
|
- [Luca Guidi] Automatically log body payload from body parsers
|
||||||
|
@ -65,7 +90,7 @@ end
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- [Anton Davydov] Make possible to pass extra settings for custom logger instances (eg. `logger SemanticLogger.new, :foo, :bar`)
|
- [Anton Davydov] Make possible to pass extra settings for custom logger instances (eg. `logger SemanticLogger.new, :foo, :bar`)
|
||||||
- [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/enviroment.rb`
|
- [graywolf] Ensure `hanami generate app` to work without `require_relative` entries in `config/environment.rb`
|
||||||
- [Makoto Tajitsu & Luca Guidi] Fixed regression for `hanami new .` that used to generate a broken project
|
- [Makoto Tajitsu & Luca Guidi] Fixed regression for `hanami new .` that used to generate a broken project
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -182,7 +207,7 @@ end
|
||||||
- [Luca Guidi] Make compatible with Rack 2.0 only
|
- [Luca Guidi] Make compatible with Rack 2.0 only
|
||||||
- [Luca Guidi] Removed `logger` settings from Hanami applications
|
- [Luca Guidi] Removed `logger` settings from Hanami applications
|
||||||
- [Luca Guidi] Removed logger for Hanami applications (eg `Web.logger`)
|
- [Luca Guidi] Removed logger for Hanami applications (eg `Web.logger`)
|
||||||
- [Luca Guidi] Changed mailer syntax in `config/enviroment.rb`
|
- [Luca Guidi] Changed mailer syntax in `config/environment.rb`
|
||||||
|
|
||||||
## v0.9.2 - 2016-12-19
|
## v0.9.2 - 2016-12-19
|
||||||
## Added
|
## Added
|
||||||
|
@ -271,11 +296,11 @@ end
|
||||||
|
|
||||||
## v0.7.2 - 2016-02-09
|
## v0.7.2 - 2016-02-09
|
||||||
### Fixed
|
### Fixed
|
||||||
- [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to hijiack paths that are matching directories in public directory
|
- [Alfonso Uceda Pompa] Fixed routing issue when static assets server tried to hijack paths that are matching directories in public directory
|
||||||
|
|
||||||
## v0.7.1 - 2016-02-05
|
## v0.7.1 - 2016-02-05
|
||||||
### Fixed
|
### Fixed
|
||||||
- [Anton Davydov] Fixed routing issue when static assets server tried to hijiack requests belonging to dynamic endpoints
|
- [Anton Davydov] Fixed routing issue when static assets server tried to hijack requests belonging to dynamic endpoints
|
||||||
- [Anatolii Didukh] Ensure to fallback to default engine for `hanami console`
|
- [Anatolii Didukh] Ensure to fallback to default engine for `hanami console`
|
||||||
|
|
||||||
## v0.7.0 - 2016-01-22
|
## v0.7.0 - 2016-01-22
|
||||||
|
@ -410,7 +435,7 @@ end
|
||||||
## v0.3.0 - 2015-03-23
|
## v0.3.0 - 2015-03-23
|
||||||
### Added
|
### Added
|
||||||
- [Luca Guidi] Introduced action generator. Eg. `bundle exec lotus generate action web dashboard#index`
|
- [Luca Guidi] Introduced action generator. Eg. `bundle exec lotus generate action web dashboard#index`
|
||||||
- [Alfonso Uceda Pompa] Allow to specify default coookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
|
- [Alfonso Uceda Pompa] Allow to specify default cookies options in application configuration. Eg. `cookies true, { domain: 'lotusrb.org' }`
|
||||||
- [Tom Kadwill] Include `Lotus::Helpers` in views.
|
- [Tom Kadwill] Include `Lotus::Helpers` in views.
|
||||||
- [Linus Pettersson] Allow to specify `--database` CLI option when generate a new project. Eg. `lotus new bookshelf --database=postgresql`
|
- [Linus Pettersson] Allow to specify `--database` CLI option when generate a new project. Eg. `lotus new bookshelf --database=postgresql`
|
||||||
- [Linus Pettersson] Initialize a Git repository when generating a new project
|
- [Linus Pettersson] Initialize a Git repository when generating a new project
|
||||||
|
|
10
FEATURES.md
10
FEATURES.md
|
@ -5,6 +5,14 @@
|
||||||
|
|
||||||
## v2.0.0.alpha1 - 2019-01-30
|
## v2.0.0.alpha1 - 2019-01-30
|
||||||
|
|
||||||
|
## v1.3.3 - 2019-09-20
|
||||||
|
|
||||||
|
- Standardize file loading for `.env` files (see: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)
|
||||||
|
|
||||||
|
## v1.3.2 - 2019-07-26
|
||||||
|
|
||||||
|
## v1.3.1 - 2019-01-18
|
||||||
|
|
||||||
## v1.3.0 - 2018-10-24
|
## v1.3.0 - 2018-10-24
|
||||||
|
|
||||||
- Default testing framework is RSpec
|
- Default testing framework is RSpec
|
||||||
|
@ -20,7 +28,7 @@
|
||||||
- Unobtrusive JavaScript (UJS) (via `hanami-ujs` gem)
|
- Unobtrusive JavaScript (UJS) (via `hanami-ujs` gem)
|
||||||
- Interactive console for development error page (via `hanami-webconsole` gem)
|
- Interactive console for development error page (via `hanami-webconsole` gem)
|
||||||
- CLI: register callbacks for `hanami` commands (`Hanami::CLI.after("db migrate", MyCallback.new)` or `Hanami::CLI.after("db migrate") { ... }`)
|
- CLI: register callbacks for `hanami` commands (`Hanami::CLI.after("db migrate", MyCallback.new)` or `Hanami::CLI.after("db migrate") { ... }`)
|
||||||
- Project level Rack middleware stack (`Hanami.configure { middleware.use MyRackMiddlewre }`)
|
- Project level Rack middleware stack (`Hanami.configure { middleware.use MyRackMiddleware }`)
|
||||||
- Plugins can hook into project configuration (`Hanami.plugin { middleware.use AnotherRackMiddleware }`)
|
- Plugins can hook into project configuration (`Hanami.plugin { middleware.use AnotherRackMiddleware }`)
|
||||||
- Custom repository commands
|
- Custom repository commands
|
||||||
- Coloured logging
|
- Coloured logging
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright © 2014-2017 Luca Guidi
|
Copyright © 2014-2021 Luca Guidi
|
||||||
|
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ which provides the glue that ties all the parts together:
|
||||||
* [**Hanami::Helpers**](https://github.com/hanami/helpers) - View helpers for Ruby applications
|
* [**Hanami::Helpers**](https://github.com/hanami/helpers) - View helpers for Ruby applications
|
||||||
* [**Hanami::Mailer**](https://github.com/hanami/mailer) - Mail for Ruby applications
|
* [**Hanami::Mailer**](https://github.com/hanami/mailer) - Mail for Ruby applications
|
||||||
* [**Hanami::Assets**](https://github.com/hanami/assets) - Assets management for Ruby
|
* [**Hanami::Assets**](https://github.com/hanami/assets) - Assets management for Ruby
|
||||||
* [**Hanami::CLI**](https://github.com/hanami/cli) - Ruby command line interface
|
|
||||||
* [**Hanami::Utils**](https://github.com/hanami/utils) - Ruby core extensions and class utilities
|
* [**Hanami::Utils**](https://github.com/hanami/utils) - Ruby core extensions and class utilities
|
||||||
|
|
||||||
These components are designed to be used independently or together in a Hanami application.
|
These components are designed to be used independently or together in a Hanami application.
|
||||||
|
@ -26,14 +25,14 @@ These components are designed to be used independently or together in a Hanami a
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
[![Gem Version](https://badge.fury.io/rb/hanami.svg)](https://badge.fury.io/rb/hanami)
|
[![Gem Version](https://badge.fury.io/rb/hanami.svg)](https://badge.fury.io/rb/hanami)
|
||||||
[![TravisCI](https://travis-ci.org/hanami/hanami.svg?branch=master)](https://travis-ci.org/hanami/hanami)
|
[![CI](https://github.com/hanami/hanami/workflows/ci/badge.svg?branch=unstable)](https://github.com/hanami/hanami/actions?query=workflow%3Aci+branch%3Aunstable)
|
||||||
[![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/hanami)
|
[![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/unstable/graph/badge.svg)](https://codecov.io/gh/hanami/hanami)
|
||||||
[![Depfu](https://badges.depfu.com/badges/ba000e0f69e6ef1c44cd3038caaa1841/overview.svg)](https://depfu.com/github/hanami/hanami?project=Bundler)
|
[![Depfu](https://badges.depfu.com/badges/ba000e0f69e6ef1c44cd3038caaa1841/overview.svg)](https://depfu.com/github/hanami/hanami?project=Bundler)
|
||||||
[![Inline Docs](http://inch-ci.org/github/hanami/hanami.svg)](http://inch-ci.org/github/hanami/hanami)
|
[![Inline Docs](http://inch-ci.org/github/hanami/hanami.svg)](http://inch-ci.org/github/hanami/hanami)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
__Hanami__ supports Ruby (MRI) 2.5+
|
__Hanami__ supports Ruby (MRI) 2.6+
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
gem install hanami
|
gem install hanami
|
||||||
|
@ -137,4 +136,4 @@ Released under MIT License.
|
||||||
|
|
||||||
This project was formerly known as Lotus (`lotusrb`).
|
This project was formerly known as Lotus (`lotusrb`).
|
||||||
|
|
||||||
Copyright © 2014-2019 Luca Guidi.
|
Copyright © 2014-2021 Luca Guidi.
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
require "bundler"
|
require "bundler"
|
||||||
require "hanami/cli/commands"
|
require "hanami/cli/commands"
|
||||||
|
|
||||||
Bundler.require(*Hanami.bundler_groups) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
|
::Bundler.require(:plugins) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
|
||||||
Hanami::CLI.new(Hanami::CLI::Commands).call
|
Dry::CLI.new(Hanami::CLI::Commands).call
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "hanami/cli"
|
require "dry/cli"
|
||||||
|
require "ostruct"
|
||||||
|
|
||||||
module Hanami
|
module Hanami
|
||||||
# Hanami CLI
|
# Hanami CLI
|
||||||
|
@ -55,7 +56,7 @@ module Hanami
|
||||||
# @since 1.1.0
|
# @since 1.1.0
|
||||||
# @api private
|
# @api private
|
||||||
module Commands
|
module Commands
|
||||||
extend Hanami::CLI::Registry
|
extend Dry::CLI::Registry
|
||||||
|
|
||||||
require "hanami/cli/commands/command"
|
require "hanami/cli/commands/command"
|
||||||
require "hanami/cli/commands/server"
|
require "hanami/cli/commands/server"
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Hanami
|
||||||
# Abstract command
|
# Abstract command
|
||||||
#
|
#
|
||||||
# @since 1.1.0
|
# @since 1.1.0
|
||||||
class Command < Hanami::CLI::Command
|
class Command < Dry::CLI::Command
|
||||||
# @since 1.1.0
|
# @since 1.1.0
|
||||||
# @api private
|
# @api private
|
||||||
def self.inherited(component)
|
def self.inherited(component)
|
||||||
|
@ -70,22 +70,46 @@ module Hanami
|
||||||
# @since 1.1.0
|
# @since 1.1.0
|
||||||
# @api private
|
# @api private
|
||||||
def call(**options)
|
def call(**options)
|
||||||
|
<<<<<<< HEAD
|
||||||
# FIXME: merge ENV vars (like HANAMI_ENV) into **options
|
# FIXME: merge ENV vars (like HANAMI_ENV) into **options
|
||||||
super(options)
|
super(options)
|
||||||
rescue StandardError => exception
|
rescue StandardError => exception
|
||||||
warn exception.message
|
warn exception.message
|
||||||
warn exception.backtrace.join("\n\t")
|
warn exception.backtrace.join("\n\t")
|
||||||
|
=======
|
||||||
|
if self.class.requirements.any?
|
||||||
|
environment = Hanami::Environment.new(options)
|
||||||
|
environment.require_project_environment
|
||||||
|
|
||||||
|
requirements.resolved('environment', environment)
|
||||||
|
requirements.resolve(self.class.requirements)
|
||||||
|
|
||||||
|
options = environment.to_options.merge(options)
|
||||||
|
end
|
||||||
|
|
||||||
|
super(**options)
|
||||||
|
rescue StandardError => e
|
||||||
|
warn e.message
|
||||||
|
warn e.backtrace.join("\n\t")
|
||||||
|
>>>>>>> develop
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# @since 1.1.0
|
# @since 1.1.0
|
||||||
# @api private
|
# @api private
|
||||||
|
<<<<<<< HEAD
|
||||||
def initialize(command_name:, out: $stdout, files: Utils::Files)
|
def initialize(command_name:, out: $stdout, files: Utils::Files)
|
||||||
super(command_name: command_name)
|
super(command_name: command_name)
|
||||||
|
|
||||||
@out = out
|
@out = out
|
||||||
@files = files
|
@files = files
|
||||||
|
=======
|
||||||
|
def initialize(out: $stdout, files: Utils::Files)
|
||||||
|
@out = out
|
||||||
|
@files = files
|
||||||
|
@templates = Templates.new(self.class)
|
||||||
|
>>>>>>> develop
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
16
script/ci
16
script/ci
|
@ -3,9 +3,9 @@ set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
remove_coverage &&
|
remove_coverage
|
||||||
print_ruby_version &&
|
print_ruby_version
|
||||||
install_gems
|
install_gems
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_coverage() {
|
remove_coverage() {
|
||||||
|
@ -73,11 +73,11 @@ upload_code_coverage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
setup &&
|
setup
|
||||||
run_unit_tests &&
|
run_unit_tests
|
||||||
run_isolation_tests &&
|
run_isolation_tests
|
||||||
run_code_quality_checks &&
|
run_integration_tests
|
||||||
upload_code_coverage
|
upload_code_coverage
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
|
@ -20,7 +20,7 @@ bundle_package() {
|
||||||
}
|
}
|
||||||
|
|
||||||
install_hanami_frameworks() {
|
install_hanami_frameworks() {
|
||||||
declare -a frameworks=(utils validations router helpers model view controller mailer assets cli webconsole)
|
declare -a frameworks=(utils validations router helpers model view controller mailer assets webconsole)
|
||||||
|
|
||||||
for framework in "${frameworks[@]}"
|
for framework in "${frameworks[@]}"
|
||||||
do
|
do
|
||||||
|
|
|
@ -3,7 +3,7 @@ set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
uninstall_hanami_gems() {
|
uninstall_hanami_gems() {
|
||||||
declare -a frameworks=(hanami hanami-assets hanami-mailer hanami-controller hanami-view hanami-model hanami-helpers hanami-router hanami-validations hanami-cli hanami-webconsole hanami-utils)
|
declare -a frameworks=(hanami hanami-assets hanami-mailer hanami-controller hanami-view hanami-model hanami-helpers hanami-router hanami-validations hanami-webconsole hanami-utils)
|
||||||
|
|
||||||
for framework in "${frameworks[@]}"
|
for framework in "${frameworks[@]}"
|
||||||
do
|
do
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
run_tests() {
|
||||||
|
local type=$1
|
||||||
|
local pwd=$PWD
|
||||||
|
local root="$pwd/spec/$type"
|
||||||
|
|
||||||
|
for test in $(find $root -name '*_spec.rb')
|
||||||
|
do
|
||||||
|
run_test $root $test
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
local exit_code=$?
|
||||||
|
echo "Failing test: $test"
|
||||||
|
exit $exit_code
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
run_test() {
|
||||||
|
local root=$1
|
||||||
|
local test=$2
|
||||||
|
local hash="$(shasum "$test" | cut -b 1-40)"
|
||||||
|
|
||||||
|
printf "\n\n\nRunning: $test\n"
|
||||||
|
SIMPLECOV_COMMAND_NAME=$hash bundle exec rspec $test
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local type=$1
|
||||||
|
run_tests $type
|
||||||
|
}
|
||||||
|
|
||||||
|
main $1
|
|
@ -5,7 +5,7 @@ RSpec.describe "assets", type: :integration do
|
||||||
it "compiles and serves assets in development mode" do
|
it "compiles and serves assets in development mode" do
|
||||||
project = "bookshelf_serve_assets"
|
project = "bookshelf_serve_assets"
|
||||||
|
|
||||||
with_project(project, gems: ["sass"]) do
|
with_project(project, gems: ['sassc']) do
|
||||||
generate "action web home#index --url=/"
|
generate "action web home#index --url=/"
|
||||||
|
|
||||||
write "apps/web/assets/javascripts/application.css.sass", <<~EOF
|
write "apps/web/assets/javascripts/application.css.sass", <<~EOF
|
||||||
|
|
|
@ -45,6 +45,6 @@ RSpec.describe "body parsers", type: :integration do
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable_json_body_parser
|
def enable_json_body_parser
|
||||||
replace "apps/web/application.rb", "# body_parsers :json", "body_parsers :json"
|
inject_line_after "apps/web/application.rb", "configure do", "body_parsers :json"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ require "json"
|
||||||
RSpec.describe "hanami assets", type: :integration do
|
RSpec.describe "hanami assets", type: :integration do
|
||||||
describe "precompile" do
|
describe "precompile" do
|
||||||
it "precompiles assets" do
|
it "precompiles assets" do
|
||||||
gems = %w[sass coffee-script]
|
gems = %w[sassc coffee-script]
|
||||||
|
|
||||||
Platform.match do
|
Platform.match do
|
||||||
os(:linux).engine(:ruby) { gems.push("therubyracer") }
|
os(:linux).engine(:ruby) { gems.push("therubyracer") }
|
||||||
|
@ -140,7 +140,7 @@ return Dashboard;})();}).call(this);
|
||||||
hanami assets precompile HANAMI_ENV=production # Precompile assets for production environment
|
hanami assets precompile HANAMI_ENV=production # Precompile assets for production environment
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami assets precompile --help", output
|
run_cmd "hanami assets precompile --help", output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe "hanami assets", type: :integration do
|
||||||
hanami assets precompile # Precompile assets for deployment
|
hanami assets precompile # Precompile assets for deployment
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami assets", output, exit_status: 1
|
run_cmd "hanami assets", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,14 +64,14 @@ RSpec.describe "hanami console", type: :integration do
|
||||||
xit "returns error when known engine isn't bundled" do
|
xit "returns error when known engine isn't bundled" do
|
||||||
with_project("bookshelf_console_irb", console: :irb) do
|
with_project("bookshelf_console_irb", console: :irb) do
|
||||||
output = "Missing gem for `pry' console engine. Please make sure to add it to `Gemfile'."
|
output = "Missing gem for `pry' console engine. Please make sure to add it to `Gemfile'."
|
||||||
run_command "hanami console --engine=pry", output, exit_status: 1
|
run_cmd "hanami console --engine=pry", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns error when unknown engine is requested" do
|
it "returns error when unknown engine is requested" do
|
||||||
with_project("bookshelf_console_irb", console: :irb) do
|
with_project("bookshelf_console_irb", console: :irb) do
|
||||||
output = "Unknown console engine: `foo'."
|
output = "Unknown console engine: `foo'."
|
||||||
run_command "hanami console --engine=foo", output, exit_status: 1
|
run_cmd "hanami console --engine=foo", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ RSpec.describe "hanami console", type: :integration do
|
||||||
hanami console --engine=pry # Force to use Pry
|
hanami console --engine=pry # Force to use Pry
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami console --help", output
|
run_cmd "hanami console --help", output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
RSpec.describe "hanami db", type: :integration do
|
RSpec.describe "hanami db", type: :integration do
|
||||||
describe "apply" do
|
describe "apply" do
|
||||||
it "migrates, dumps structure, deletes migrations" do
|
it "migrates, dumps structure, deletes migrations", if: RUBY_VERSION < '2.4' do
|
||||||
with_project do
|
with_project do
|
||||||
versions = generate_migrations
|
versions = generate_migrations
|
||||||
|
|
||||||
|
@ -26,6 +26,31 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "migrates, dumps structure, deletes migrations", if: RUBY_VERSION >= '2.4' do
|
||||||
|
with_project do
|
||||||
|
versions = generate_migrations
|
||||||
|
|
||||||
|
hanami "db apply"
|
||||||
|
|
||||||
|
hanami "db version"
|
||||||
|
expect(out).to include(versions.last.to_s)
|
||||||
|
|
||||||
|
db = Pathname.new('db')
|
||||||
|
schema = db.join('schema.sql').to_s
|
||||||
|
migrations = db.join('migrations')
|
||||||
|
|
||||||
|
expect(schema).to have_file_content <<-SQL
|
||||||
|
CREATE TABLE `schema_migrations` (`filename` varchar(255) NOT NULL PRIMARY KEY);
|
||||||
|
CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255), `age` integer);
|
||||||
|
CREATE TABLE sqlite_sequence(name,seq);
|
||||||
|
INSERT INTO schema_migrations VALUES('#{versions.first}_create_users.rb');
|
||||||
|
INSERT INTO schema_migrations VALUES('#{versions.last}_add_age_to_users.rb');
|
||||||
|
SQL
|
||||||
|
|
||||||
|
expect(migrations.children).to be_empty
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "prints help message" do
|
it "prints help message" do
|
||||||
with_project do
|
with_project do
|
||||||
output = <<~OUT
|
output = <<~OUT
|
||||||
|
@ -42,7 +67,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami db apply --help", output
|
run_cmd "hanami db apply --help", output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami db console --help", output
|
run_cmd "hanami db console --help", output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami db create --help", output
|
run_cmd 'hanami db create --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami db drop --help", output
|
run_cmd 'hanami db drop --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,7 +107,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
%r{ hanami db migrate [\d]{14} # Migrate to a specific version}
|
%r{ hanami db migrate [\d]{14} # Migrate to a specific version}
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami db drop --help", output
|
run_cmd 'hanami db drop --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami db prepare --help", output
|
run_cmd 'hanami db prepare --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,7 +50,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
hanami "db migrate"
|
hanami "db migrate"
|
||||||
|
|
||||||
output = "the number of steps must be a positive integer (you entered `quindici')."
|
output = "the number of steps must be a positive integer (you entered `quindici')."
|
||||||
run_command "hanami db rollback quindici", output, exit_status: 1
|
run_cmd "hanami db rollback quindici", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
hanami "db migrate"
|
hanami "db migrate"
|
||||||
|
|
||||||
output = "the number of steps must be a positive integer (you entered `0')."
|
output = "the number of steps must be a positive integer (you entered `0')."
|
||||||
run_command "hanami db rollback 0", output, exit_status: 1
|
run_cmd "hanami db rollback 0", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,11 +84,12 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
Options:
|
Options:
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
hanami db rollback # Rollbacks latest migration
|
hanami db rollback # Rollbacks latest migration
|
||||||
hanami db rollback 2 # Rollbacks last two migrations
|
hanami db rollback 2 # Rollbacks last two migrations
|
||||||
OUT
|
OUT
|
||||||
run_command "hanami db rollback --help", output
|
|
||||||
|
run_cmd 'hanami db rollback --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami db version --help", output
|
run_cmd 'hanami db version --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe "hanami db", type: :integration do
|
||||||
hanami db version # Print the current migrated version
|
hanami db version # Print the current migrated version
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami db", output, exit_status: 1
|
run_cmd "hanami db", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
"remove spec/web/controllers/books/index_spec.rb"
|
"remove spec/web/controllers/books/index_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami destroy action web books#index", output
|
run_cmd "hanami destroy action web books#index", output
|
||||||
|
|
||||||
expect("spec/web/controllers/books/index_spec.rb").to_not be_an_existing_file
|
expect("spec/web/controllers/books/index_spec.rb").to_not be_an_existing_file
|
||||||
expect("apps/web/controllers/books/index.rb").to_not be_an_existing_file
|
expect("apps/web/controllers/books/index.rb").to_not be_an_existing_file
|
||||||
|
@ -38,7 +38,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
"remove spec/web/controllers/api/books/index_spec.rb"
|
"remove spec/web/controllers/api/books/index_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami destroy action web api/books#index", output
|
run_cmd "hanami destroy action web api/books#index", output
|
||||||
|
|
||||||
expect("spec/web/controllers/api/books/index_spec.rb").to_not be_an_existing_file
|
expect("spec/web/controllers/api/books/index_spec.rb").to_not be_an_existing_file
|
||||||
expect("apps/web/controllers/api/books/index.rb").to_not be_an_existing_file
|
expect("apps/web/controllers/api/books/index.rb").to_not be_an_existing_file
|
||||||
|
@ -59,7 +59,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
"remove spec/web/controllers/home/ping_spec.rb"
|
"remove spec/web/controllers/home/ping_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami destroy action web home#ping", output
|
run_cmd "hanami destroy action web home#ping", output
|
||||||
|
|
||||||
expect("spec/web/controllers/home/ping_spec.rb").to_not be_an_existing_file
|
expect("spec/web/controllers/home/ping_spec.rb").to_not be_an_existing_file
|
||||||
expect("apps/web/controllers/home/ping.rb").to_not be_an_existing_file
|
expect("apps/web/controllers/home/ping.rb").to_not be_an_existing_file
|
||||||
|
@ -78,7 +78,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
Usage: "hanami destroy action APP ACTION"
|
Usage: "hanami destroy action APP ACTION"
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy action", output, exit_status: 1
|
run_cmd "hanami destroy action", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
Usage: "hanami destroy action APP ACTION"
|
Usage: "hanami destroy action APP ACTION"
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy action home#index", output, exit_status: 1
|
run_cmd "hanami destroy action home#index", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
with_project("bookshelf_generate_action_with_unknown_app") do
|
with_project("bookshelf_generate_action_with_unknown_app") do
|
||||||
output = "`foo' is not a valid APP. Please specify one of: `web'"
|
output = "`foo' is not a valid APP. Please specify one of: `web'"
|
||||||
|
|
||||||
run_command "hanami destroy action foo home#index", output, exit_status: 1
|
run_cmd "hanami destroy action foo home#index", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
please run `hanami routes' to know the existing actions.
|
please run `hanami routes' to know the existing actions.
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy action web home#index", output, exit_status: 1
|
run_cmd "hanami destroy action web home#index", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
hanami destroy action admin users#index # Destroy from `admin` app
|
hanami destroy action admin users#index # Destroy from `admin` app
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy action --help", output
|
run_cmd 'hanami destroy action --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # action
|
end # action
|
||||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
"remove apps/admin"
|
"remove apps/admin"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami destroy app admin", output
|
run_cmd "hanami destroy app admin", output
|
||||||
|
|
||||||
expect(".env.test").to_not have_file_content(%r{ADMIN_SESSIONS_SECRET})
|
expect(".env.test").to_not have_file_content(%r{ADMIN_SESSIONS_SECRET})
|
||||||
expect(".env.development").to_not have_file_content(%r{ADMIN_SESSIONS_SECRET})
|
expect(".env.development").to_not have_file_content(%r{ADMIN_SESSIONS_SECRET})
|
||||||
|
@ -52,7 +52,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
"remove apps/api"
|
"remove apps/api"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami destroy app api", output
|
run_cmd "hanami destroy app api", output
|
||||||
|
|
||||||
expect(".env.test").to_not have_file_content(%r{API_SESSIONS_SECRET})
|
expect(".env.test").to_not have_file_content(%r{API_SESSIONS_SECRET})
|
||||||
expect(".env.development").to_not have_file_content(%r{API_SESSIONS_SECRET})
|
expect(".env.development").to_not have_file_content(%r{API_SESSIONS_SECRET})
|
||||||
|
@ -70,20 +70,22 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
|
|
||||||
it "fails with missing argument" do
|
it "fails with missing argument" do
|
||||||
with_project do
|
with_project do
|
||||||
output = <<~OUT
|
output = <<-OUT
|
||||||
ERROR: "hanami destroy app" was called with no arguments
|
ERROR: "hanami destroy app" was called with no arguments
|
||||||
Usage: "hanami destroy app APP"
|
Usage: "hanami destroy app APP"
|
||||||
OUT
|
OUT
|
||||||
run_command "hanami destroy app", output, exit_status: 1
|
|
||||||
|
run_cmd "hanami destroy app", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails with unknown app" do
|
it "fails with unknown app" do
|
||||||
with_project do
|
with_project do
|
||||||
output = <<~OUT
|
output = <<-OUT
|
||||||
`unknown' is not a valid APP. Please specify one of: `web'
|
`unknown' is not a valid APP. Please specify one of: `web'
|
||||||
OUT
|
OUT
|
||||||
run_command "hanami destroy app unknown", output, exit_status: 1
|
|
||||||
|
run_cmd "hanami destroy app unknown", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -109,7 +111,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
hanami destroy app admin # Destroy `admin` app
|
hanami destroy app admin # Destroy `admin` app
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy app --help", output
|
run_cmd 'hanami destroy app --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # app
|
end # app
|
||||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
with_project("bookshelf_generate_mailer", test: "rspec") do
|
with_project("bookshelf_generate_mailer", test: "rspec") do
|
||||||
generate "mailer welcome"
|
generate "mailer welcome"
|
||||||
|
|
||||||
run_command "hanami destroy mailer welcome", output
|
run_cmd "hanami destroy mailer welcome", output
|
||||||
|
|
||||||
expect("spec/bookshelf_generate_mailer/mailers/welcome_spec.rb").to_not be_an_existing_file
|
expect("spec/bookshelf_generate_mailer/mailers/welcome_spec.rb").to_not be_an_existing_file
|
||||||
expect("lib/bookshelf_generate_mailer/mailers/templates/welcome.html.erb").to_not be_an_existing_file
|
expect("lib/bookshelf_generate_mailer/mailers/templates/welcome.html.erb").to_not be_an_existing_file
|
||||||
|
@ -31,7 +31,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
Usage: "hanami generate mailer MAILER"
|
Usage: "hanami generate mailer MAILER"
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate mailer", output, exit_status: 1
|
run_cmd "hanami generate mailer", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
cannot find `unknown' mailer. Please have a look at `lib/bookshelf/mailers' directory to find an existing mailer.
|
cannot find `unknown' mailer. Please have a look at `lib/bookshelf/mailers' directory to find an existing mailer.
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy mailer unknown", output, exit_status: 1
|
run_cmd "hanami destroy mailer unknown", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
hanami destroy mailer welcome # Destroy `WelcomeMailer` mailer
|
hanami destroy mailer welcome # Destroy `WelcomeMailer` mailer
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy mailer --help", output
|
run_cmd 'hanami destroy mailer --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
"remove #{migration}"
|
"remove #{migration}"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami destroy migration create_users", output
|
run_cmd "hanami destroy migration create_users", output
|
||||||
|
|
||||||
expect(migration).to_not be_an_existing_file
|
expect(migration).to_not be_an_existing_file
|
||||||
end
|
end
|
||||||
|
@ -21,20 +21,35 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
|
|
||||||
it "fails with missing argument" do
|
it "fails with missing argument" do
|
||||||
with_project do
|
with_project do
|
||||||
|
<<<<<<< HEAD
|
||||||
output = <<~OUT
|
output = <<~OUT
|
||||||
ERROR: "hanami destroy migration" was called with no arguments
|
ERROR: "hanami destroy migration" was called with no arguments
|
||||||
Usage: "hanami destroy migration MIGRATION"
|
Usage: "hanami destroy migration MIGRATION"
|
||||||
OUT
|
OUT
|
||||||
run_command "hanami destroy migration", output, exit_status: 1
|
run_command "hanami destroy migration", output, exit_status: 1
|
||||||
|
=======
|
||||||
|
output = <<-OUT
|
||||||
|
ERROR: "hanami destroy migration" was called with no arguments
|
||||||
|
Usage: "hanami destroy migration MIGRATION"
|
||||||
|
OUT
|
||||||
|
run_cmd "hanami destroy migration", output, exit_status: 1
|
||||||
|
>>>>>>> develop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails with unknown migration" do
|
it "fails with unknown migration" do
|
||||||
with_project do
|
with_project do
|
||||||
|
<<<<<<< HEAD
|
||||||
output = <<~OUT
|
output = <<~OUT
|
||||||
cannot find `create_unknowns'. Please have a look at `db/migrations' directory to find an existing migration
|
cannot find `create_unknowns'. Please have a look at `db/migrations' directory to find an existing migration
|
||||||
OUT
|
OUT
|
||||||
run_command "hanami destroy migration create_unknowns", output, exit_status: 1
|
run_command "hanami destroy migration create_unknowns", output, exit_status: 1
|
||||||
|
=======
|
||||||
|
output = <<-OUT
|
||||||
|
cannot find `create_unknowns'. Please have a look at `db/migrations' directory to find an existing migration
|
||||||
|
OUT
|
||||||
|
run_cmd "hanami destroy migration create_unknowns", output, exit_status: 1
|
||||||
|
>>>>>>> develop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,7 +78,11 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
%r{ hanami destroy migration create_users # Destroy `db/migrations/[\d]{14}_create_users.rb`}
|
%r{ hanami destroy migration create_users # Destroy `db/migrations/[\d]{14}_create_users.rb`}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
run_command "hanami destroy migration --help", output
|
run_command "hanami destroy migration --help", output
|
||||||
|
=======
|
||||||
|
run_cmd 'hanami destroy migration --help', output
|
||||||
|
>>>>>>> develop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # migration
|
end # migration
|
||||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
"remove lib/bookshelf/entities/user.rb"
|
"remove lib/bookshelf/entities/user.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami destroy model user", output
|
run_cmd "hanami destroy model user", output
|
||||||
|
|
||||||
expect(migration).to be_an_existing_file
|
expect(migration).to be_an_existing_file
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
"remove lib/bookshelf/entities/user.rb"
|
"remove lib/bookshelf/entities/user.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami destroy model user", output
|
run_cmd "hanami destroy model user", output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
Usage: "hanami destroy model MODEL"
|
Usage: "hanami destroy model MODEL"
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy model", output, exit_status: 1
|
run_cmd "hanami destroy model", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
> $ hanami destroy model car
|
> $ hanami destroy model car
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy model --help", output
|
run_cmd 'hanami destroy model --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
cannot find `unknown' model. Please have a look at `lib/bookshelf/entities' directory to find an existing model.
|
cannot find `unknown' model. Please have a look at `lib/bookshelf/entities' directory to find an existing model.
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy model unknown", output, exit_status: 1
|
run_cmd "hanami destroy model unknown", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
hanami destroy model user # Destroy `User` entity and `UserRepository` repository
|
hanami destroy model user # Destroy `User` entity and `UserRepository` repository
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy model --help", output
|
run_cmd 'hanami destroy model --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # model
|
end # model
|
||||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
||||||
hanami destroy model MODEL # Destroy a model
|
hanami destroy model MODEL # Destroy a model
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami destroy", output, exit_status: 1
|
run_cmd "hanami destroy", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"insert apps/web/config/routes.rb"
|
"insert apps/web/config/routes.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web authors#index", output
|
run_cmd "hanami generate action web authors#index", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/controllers/authors/index.rb
|
# apps/web/controllers/authors/index.rb
|
||||||
|
@ -66,7 +66,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"insert apps/web/config/routes.rb"
|
"insert apps/web/config/routes.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web api/authors#index", output
|
run_cmd "hanami generate action web api/authors#index", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/controllers/api/authors/index.rb
|
# apps/web/controllers/api/authors/index.rb
|
||||||
|
@ -114,7 +114,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
|
|
||||||
it "generates non-RESTful actions" do
|
it "generates non-RESTful actions" do
|
||||||
with_project do
|
with_project do
|
||||||
run_command "hanami generate action web sessions#sign_out"
|
run_cmd "hanami generate action web sessions#sign_out"
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/config/routes.rb
|
# apps/web/config/routes.rb
|
||||||
|
@ -129,7 +129,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
ERROR: "hanami generate action" was called with no arguments
|
ERROR: "hanami generate action" was called with no arguments
|
||||||
Usage: "hanami generate action APP ACTION"
|
Usage: "hanami generate action APP ACTION"
|
||||||
OUT
|
OUT
|
||||||
run_command "hanami generate action", output, exit_status: 1
|
run_cmd "hanami generate action", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
Usage: "hanami generate action APP ACTION"
|
Usage: "hanami generate action APP ACTION"
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate action home#index", output, exit_status: 1
|
run_cmd "hanami generate action home#index", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
with_project("bookshelf_generate_action_with_unknown_app") do
|
with_project("bookshelf_generate_action_with_unknown_app") do
|
||||||
output = "`foo' is not a valid APP. Please specify one of: `web'"
|
output = "`foo' is not a valid APP. Please specify one of: `web'"
|
||||||
|
|
||||||
run_command "hanami generate action foo home#index", output, exit_status: 1
|
run_cmd "hanami generate action foo home#index", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"insert apps/web/config/routes.rb"
|
"insert apps/web/config/routes.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web home#index --url=/", output
|
run_cmd "hanami generate action web home#index --url=/", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/config/routes.rb
|
# apps/web/config/routes.rb
|
||||||
|
@ -171,7 +171,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
it "fails with missing argument" do
|
it "fails with missing argument" do
|
||||||
with_project("bookshelf_generate_action_missing_url") do
|
with_project("bookshelf_generate_action_missing_url") do
|
||||||
output = "`' is not a valid URL"
|
output = "`' is not a valid URL"
|
||||||
run_command "hanami generate action web books#create --url=", output, exit_status: 1
|
run_cmd "hanami generate action web books#create --url=", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -184,7 +184,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create spec/web/controllers/status/check_spec.rb",
|
"create spec/web/controllers/status/check_spec.rb",
|
||||||
"insert apps/web/config/routes.rb"
|
"insert apps/web/config/routes.rb"
|
||||||
]
|
]
|
||||||
run_command "hanami generate action web status#check --skip-view", output
|
run_cmd "hanami generate action web status#check --skip-view", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/controllers/status/check.rb
|
# apps/web/controllers/status/check.rb
|
||||||
|
@ -214,7 +214,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create spec/web/controllers/api/authors/index_spec.rb",
|
"create spec/web/controllers/api/authors/index_spec.rb",
|
||||||
"insert apps/web/config/routes.rb"
|
"insert apps/web/config/routes.rb"
|
||||||
]
|
]
|
||||||
run_command "hanami generate action web api/authors#index --skip-view", output
|
run_cmd "hanami generate action web api/authors#index --skip-view", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/controllers/status/check.rb
|
# apps/web/controllers/status/check.rb
|
||||||
|
@ -247,7 +247,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"insert apps/web/config/routes.rb"
|
"insert apps/web/config/routes.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web books#create --method=POST", output
|
run_cmd "hanami generate action web books#create --method=POST", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/config/routes.rb
|
# apps/web/config/routes.rb
|
||||||
|
@ -259,14 +259,14 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
it "fails with missing argument" do
|
it "fails with missing argument" do
|
||||||
with_project("bookshelf_generate_action_missing_method") do
|
with_project("bookshelf_generate_action_missing_method") do
|
||||||
output = "`' is not a valid HTTP method. Please use one of: `GET' `POST' `PUT' `DELETE' `HEAD' `OPTIONS' `TRACE' `PATCH' `OPTIONS' `LINK' `UNLINK'"
|
output = "`' is not a valid HTTP method. Please use one of: `GET' `POST' `PUT' `DELETE' `HEAD' `OPTIONS' `TRACE' `PATCH' `OPTIONS' `LINK' `UNLINK'"
|
||||||
run_command "hanami generate action web books#create --method=", output, exit_status: 1
|
run_cmd "hanami generate action web books#create --method=", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails with unknown argument" do
|
it "fails with unknown argument" do
|
||||||
with_project("bookshelf_generate_action_uknown_method") do
|
with_project('bookshelf_generate_action_unknown_method') do
|
||||||
output = "`FOO' is not a valid HTTP method. Please use one of: `GET' `POST' `PUT' `DELETE' `HEAD' `OPTIONS' `TRACE' `PATCH' `OPTIONS' `LINK' `UNLINK'"
|
output = "`FOO' is not a valid HTTP method. Please use one of: `GET' `POST' `PUT' `DELETE' `HEAD' `OPTIONS' `TRACE' `PATCH' `OPTIONS' `LINK' `UNLINK'"
|
||||||
run_command "hanami generate action web books#create --method=FOO", output, exit_status: 1
|
run_cmd "hanami generate action web books#create --method=FOO", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -278,7 +278,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create apps/web/templates/books/index.html.erb"
|
"create apps/web/templates/books/index.html.erb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web books#index", output
|
run_cmd "hanami generate action web books#index", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/templates/books/index.html.erb
|
# apps/web/templates/books/index.html.erb
|
||||||
|
@ -301,7 +301,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create apps/web/templates/books/index.html.haml"
|
"create apps/web/templates/books/index.html.haml"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web books#index", output
|
run_cmd "hanami generate action web books#index", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/templates/books/index.html.haml
|
# apps/web/templates/books/index.html.haml
|
||||||
|
@ -324,7 +324,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create apps/web/templates/books/index.html.slim"
|
"create apps/web/templates/books/index.html.slim"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web books#index", output
|
run_cmd "hanami generate action web books#index", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/templates/books/index.html.slim
|
# apps/web/templates/books/index.html.slim
|
||||||
|
@ -348,7 +348,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create spec/web/views/books/index_spec.rb"
|
"create spec/web/views/books/index_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web books#index", output
|
run_cmd "hanami generate action web books#index", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# spec/web/controllers/books/index_spec.rb
|
# spec/web/controllers/books/index_spec.rb
|
||||||
|
@ -396,7 +396,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create spec/web/views/books/index_spec.rb"
|
"create spec/web/views/books/index_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate action web books#index", output
|
run_cmd "hanami generate action web books#index", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# spec/web/controllers/books/index_spec.rb
|
# spec/web/controllers/books/index_spec.rb
|
||||||
|
@ -462,7 +462,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
hanami generate action web books#create --skip-view # Skip view and template
|
hanami generate action web books#create --skip-view # Skip view and template
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate action --help", output
|
run_cmd 'hanami generate action --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # action
|
end # action
|
||||||
|
|
|
@ -47,7 +47,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
.join("")
|
.join("")
|
||||||
)
|
)
|
||||||
|
|
||||||
run_command "hanami generate app #{app}", output
|
run_cmd "hanami generate app #{app}", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# config/environment.rb
|
# config/environment.rb
|
||||||
|
@ -67,7 +67,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"insert config/environment.rb"
|
"insert config/environment.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate app #{app} --application-base-url=/api/v1", output
|
run_cmd "hanami generate app #{app} --application-base-url=/api/v1", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# config/environment.rb
|
# config/environment.rb
|
||||||
|
@ -80,7 +80,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
it "fails with missing argument" do
|
it "fails with missing argument" do
|
||||||
with_project("bookshelf_generate_app_missing_application_base_url") do
|
with_project("bookshelf_generate_app_missing_application_base_url") do
|
||||||
output = "`' is not a valid URL"
|
output = "`' is not a valid URL"
|
||||||
run_command "hanami generate app foo --application-base-url=", output, exit_status: 1
|
run_cmd "hanami generate app foo --application-base-url=", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -94,7 +94,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create apps/#{app}/templates/application.html.erb"
|
"create apps/#{app}/templates/application.html.erb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate app #{app}", output
|
run_cmd "hanami generate app #{app}", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/admin/templates/application.html.erb
|
# apps/admin/templates/application.html.erb
|
||||||
|
@ -128,7 +128,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create apps/#{app}/templates/application.html.haml"
|
"create apps/#{app}/templates/application.html.haml"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate app #{app}", output
|
run_cmd "hanami generate app #{app}", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/admin/templates/application.html.haml
|
# apps/admin/templates/application.html.haml
|
||||||
|
@ -160,7 +160,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create apps/#{app}/templates/application.html.slim"
|
"create apps/#{app}/templates/application.html.slim"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate app #{app}", output
|
run_cmd "hanami generate app #{app}", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/admin/templates/application.html.slim
|
# apps/admin/templates/application.html.slim
|
||||||
|
@ -208,7 +208,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
hanami generate app api --application-base-url=/api/v1 # Generate `api` app and mount at `/api/v1`
|
hanami generate app api --application-base-url=/api/v1 # Generate `api` app and mount at `/api/v1`
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate app --help", output
|
run_cmd 'hanami generate app --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # app
|
end # app
|
||||||
|
|
|
@ -10,9 +10,9 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create lib/bookshelf_generate_mailer/mailers/templates/welcome.html.erb"]
|
"create lib/bookshelf_generate_mailer/mailers/templates/welcome.html.erb"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "generate the mailer files" do
|
it 'generate the mailer files' do
|
||||||
with_project("bookshelf_generate_mailer", test: "rspec") do
|
with_project('bookshelf_generate_mailer', test: 'rspec') do
|
||||||
run_command "hanami generate mailer welcome", output
|
run_cmd "hanami generate mailer welcome", output
|
||||||
#
|
#
|
||||||
# lib/bookshelf_generate_mailer/mailers/welcome.rb
|
# lib/bookshelf_generate_mailer/mailers/welcome.rb
|
||||||
#
|
#
|
||||||
|
@ -33,9 +33,9 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "generates a proper minitest file" do
|
it 'generates a proper minitest file' do
|
||||||
with_project("bookshelf_generate_mailer", test: "minitest") do
|
with_project('bookshelf_generate_mailer', test: 'minitest') do
|
||||||
run_command "hanami generate mailer welcome", output
|
run_cmd "hanami generate mailer welcome", output
|
||||||
#
|
#
|
||||||
# spec/bookshelf_generate_mailer/mailers/welcome_spec.rb
|
# spec/bookshelf_generate_mailer/mailers/welcome_spec.rb
|
||||||
#
|
#
|
||||||
|
@ -51,9 +51,9 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "generates a proper RSpec file" do
|
it 'generates a proper RSpec file' do
|
||||||
with_project("bookshelf_generate_mailer", test: "rspec") do
|
with_project('bookshelf_generate_mailer', test: 'rspec') do
|
||||||
run_command "hanami generate mailer welcome", output
|
run_cmd "hanami generate mailer welcome", output
|
||||||
#
|
#
|
||||||
# spec/bookshelf_generate_mailer/mailers/welcome_spec.rb
|
# spec/bookshelf_generate_mailer/mailers/welcome_spec.rb
|
||||||
#
|
#
|
||||||
|
@ -77,7 +77,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create lib/bookshelf_generate_mailer_with_options/mailers/templates/welcome.html.erb"
|
"create lib/bookshelf_generate_mailer_with_options/mailers/templates/welcome.html.erb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate mailer welcome --from=\"'mail@example.com'\" --to=\"'user@example.com'\" --subject=\"'Let\'s start'\"", output
|
run_cmd "hanami generate mailer welcome --from=\"'mail@example.com'\" --to=\"'user@example.com'\" --subject=\"'Let\'s start'\"", output
|
||||||
|
|
||||||
expect("lib/bookshelf_generate_mailer_with_options/mailers/welcome.rb").to have_file_content <<~END
|
expect("lib/bookshelf_generate_mailer_with_options/mailers/welcome.rb").to have_file_content <<~END
|
||||||
module Mailers
|
module Mailers
|
||||||
|
@ -102,7 +102,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create lib/bookshelf_generate_mailer_with_options/mailers/templates/welcome.html.erb"
|
"create lib/bookshelf_generate_mailer_with_options/mailers/templates/welcome.html.erb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate mailer welcome --from='\"mail@example.com\"' --to='\"user@example.com\"' --subject='\"Come on \"Folks\"\"'", output
|
run_cmd "hanami generate mailer welcome --from='\"mail@example.com\"' --to='\"user@example.com\"' --subject='\"Come on \"Folks\"\"'", output
|
||||||
|
|
||||||
expect("lib/bookshelf_generate_mailer_with_options/mailers/welcome.rb").to have_file_content <<~END
|
expect("lib/bookshelf_generate_mailer_with_options/mailers/welcome.rb").to have_file_content <<~END
|
||||||
module Mailers
|
module Mailers
|
||||||
|
@ -127,7 +127,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create lib/bookshelf_generate_mailer_with_options/mailers/templates/welcome.html.erb"
|
"create lib/bookshelf_generate_mailer_with_options/mailers/templates/welcome.html.erb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate mailer welcome --from=mail@example.com --to=user@example.com --subject=Welcome", output
|
run_cmd "hanami generate mailer welcome --from=mail@example.com --to=user@example.com --subject=Welcome", output
|
||||||
|
|
||||||
expect("lib/bookshelf_generate_mailer_with_options/mailers/welcome.rb").to have_file_content <<~END
|
expect("lib/bookshelf_generate_mailer_with_options/mailers/welcome.rb").to have_file_content <<~END
|
||||||
module Mailers
|
module Mailers
|
||||||
|
@ -150,7 +150,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
Usage: "hanami generate mailer MAILER"
|
Usage: "hanami generate mailer MAILER"
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate mailer", output, exit_status: 1
|
run_cmd "hanami generate mailer", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
hanami generate mailer forgot_password --subject="Your password reset" # Generate with default `subject`
|
hanami generate mailer forgot_password --subject="Your password reset" # Generate with default `subject`
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate mailer --help", output
|
run_cmd 'hanami generate mailer --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,12 +28,13 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
|
|
||||||
context "with missing argument" do
|
context "with missing argument" do
|
||||||
it "fails" do
|
it "fails" do
|
||||||
with_project("bookshelf_generate_migration_missing_arguments") do
|
with_project('bookshelf_generate_migration_missing_arguments') do
|
||||||
output = <<~END
|
output = <<-END
|
||||||
ERROR: "hanami generate migration" was called with no arguments
|
ERROR: "hanami generate migration" was called with no arguments
|
||||||
Usage: "hanami generate migration MIGRATION"
|
Usage: "hanami generate migration MIGRATION"
|
||||||
END
|
END
|
||||||
run_command "hanami generate migration", output, exit_status: 1
|
|
||||||
|
run_cmd "hanami generate migration", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -64,7 +65,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
%r{ hanami generate migration create_users # Generate `db/migrations/[\d]{14}_create_users.rb`}
|
%r{ hanami generate migration create_users # Generate `db/migrations/[\d]{14}_create_users.rb`}
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate migration --help", output
|
run_cmd 'hanami generate migration --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # migration
|
end # migration
|
||||||
|
|
|
@ -30,12 +30,13 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
|
|
||||||
context "with missing argument" do
|
context "with missing argument" do
|
||||||
it "fails" do
|
it "fails" do
|
||||||
with_project("bookshelf_generate_model_missing_arguments") do
|
with_project('bookshelf_generate_model_missing_arguments') do
|
||||||
output = <<~END
|
output = <<-END
|
||||||
ERROR: "hanami generate model" was called with no arguments
|
ERROR: "hanami generate model" was called with no arguments
|
||||||
Usage: "hanami generate model MODEL"
|
Usage: "hanami generate model MODEL"
|
||||||
END
|
END
|
||||||
run_command "hanami generate model", output, exit_status: 1
|
|
||||||
|
run_cmd "hanami generate model", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -47,7 +48,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
directory = Pathname.new("db").join("migrations")
|
directory = Pathname.new("db").join("migrations")
|
||||||
FileUtils.rm_rf(directory)
|
FileUtils.rm_rf(directory)
|
||||||
|
|
||||||
run_command "hanami generate model #{model_name}"
|
run_cmd "hanami generate model #{model_name}"
|
||||||
expect(directory).to be_directory
|
expect(directory).to be_directory
|
||||||
|
|
||||||
migration = directory.children.find do |m|
|
migration = directory.children.find do |m|
|
||||||
|
@ -65,7 +66,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
table_name = "users"
|
table_name = "users"
|
||||||
project = "bookshelf_generate_model_skip_migration"
|
project = "bookshelf_generate_model_skip_migration"
|
||||||
with_project(project) do
|
with_project(project) do
|
||||||
run_command "hanami generate model #{model_name} --skip-migration"
|
run_cmd "hanami generate model #{model_name} --skip-migration"
|
||||||
#
|
#
|
||||||
# db/migrations/<timestamp>_create_<models>.rb
|
# db/migrations/<timestamp>_create_<models>.rb
|
||||||
#
|
#
|
||||||
|
@ -83,7 +84,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
table_name = "accounts"
|
table_name = "accounts"
|
||||||
project = "bookshelf_generate_model_skip_migration"
|
project = "bookshelf_generate_model_skip_migration"
|
||||||
with_project(project) do
|
with_project(project) do
|
||||||
run_command "hanami generate model #{model_name} --skip-migration --relation=#{table_name}"
|
run_cmd "hanami generate model #{model_name} --skip-migration --relation=#{table_name}"
|
||||||
#
|
#
|
||||||
# db/migrations/<timestamp>_create_<models>.rb
|
# db/migrations/<timestamp>_create_<models>.rb
|
||||||
#
|
#
|
||||||
|
@ -111,7 +112,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
/create db\/migrations\/(\d+)_create_#{relation_name}.rb/
|
/create db\/migrations\/(\d+)_create_#{relation_name}.rb/
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate model #{model_name} --relation=#{relation_name}", output
|
run_cmd "hanami generate model #{model_name} --relation=#{relation_name}", output
|
||||||
|
|
||||||
expect("lib/#{project}/repositories/#{model_name}_repository.rb").to have_file_content <<~END
|
expect("lib/#{project}/repositories/#{model_name}_repository.rb").to have_file_content <<~END
|
||||||
class #{class_name}Repository < Hanami::Repository
|
class #{class_name}Repository < Hanami::Repository
|
||||||
|
@ -148,7 +149,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
/create db\/migrations\/(\d+)_create_#{relation_name}.rb/
|
/create db\/migrations\/(\d+)_create_#{relation_name}.rb/
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate model #{model} --relation=BlackSheeps", output
|
run_cmd "hanami generate model #{model} --relation=BlackSheeps", output
|
||||||
|
|
||||||
expect("lib/#{project}/repositories/sheep_repository.rb").to have_file_content <<~END
|
expect("lib/#{project}/repositories/sheep_repository.rb").to have_file_content <<~END
|
||||||
class SheepRepository < Hanami::Repository
|
class SheepRepository < Hanami::Repository
|
||||||
|
@ -177,7 +178,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
|
|
||||||
it "returns error for blank option" do
|
it "returns error for blank option" do
|
||||||
with_project(project) do
|
with_project(project) do
|
||||||
run_command "hanami generate model #{model_name} --relation=", "`' is not a valid relation name", exit_status: 1
|
run_cmd "hanami generate model #{model_name} --relation=", "`' is not a valid relation name", exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -194,7 +195,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create spec/#{project}/repositories/#{model}_repository_spec.rb"
|
"create spec/#{project}/repositories/#{model}_repository_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate model #{model}", output
|
run_cmd "hanami generate model #{model}", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# spec/<project>/entities/<model>_spec.rb
|
# spec/<project>/entities/<model>_spec.rb
|
||||||
|
@ -233,7 +234,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
"create spec/#{project}/repositories/#{model}_repository_spec.rb"
|
"create spec/#{project}/repositories/#{model}_repository_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate model #{model}", output
|
run_cmd "hanami generate model #{model}", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# spec/<project>/entities/<model>_spec.rb
|
# spec/<project>/entities/<model>_spec.rb
|
||||||
|
@ -282,7 +283,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
hanami generate model user --relation=accounts # Generate `User` entity, `UserRepository` and migration to create `accounts` table
|
hanami generate model user --relation=accounts # Generate `User` entity, `UserRepository` and migration to create `accounts` table
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate model --help", output
|
run_cmd 'hanami generate model --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # model
|
end # model
|
||||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
%r{ hanami generate secret web # Prints session secret (eg. `WEB_SESSIONS_SECRET=[\w]{64}`)}
|
%r{ hanami generate secret web # Prints session secret (eg. `WEB_SESSIONS_SECRET=[\w]{64}`)}
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate secret --help", output
|
run_cmd 'hanami generate secret --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # secret
|
end # secret
|
||||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe "hanami generate", type: :integration do
|
||||||
hanami generate secret [APP] # Generate session secret
|
hanami generate secret [APP] # Generate session secret
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate", output, exit_status: 1
|
run_cmd "hanami generate", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
"create db/schema.sql"
|
"create db/schema.sql"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami new #{project} --database=postgres", output
|
run_cmd "hanami new #{project} --database=postgres", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
|
@ -63,9 +63,11 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
#
|
#
|
||||||
# .gitignore
|
# .gitignore
|
||||||
#
|
#
|
||||||
expect(".gitignore").to have_file_content <<~END
|
expect(".gitignore").to have_file_content <<-END
|
||||||
/public/assets*
|
/public/assets*
|
||||||
/tmp
|
/tmp
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
END
|
END
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -79,7 +81,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
"create db/schema.sql"
|
"create db/schema.sql"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami new #{project} --database=sqlite", output
|
run_cmd "hanami new #{project} --database=sqlite", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
|
@ -132,10 +134,12 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
#
|
#
|
||||||
# .gitignore
|
# .gitignore
|
||||||
#
|
#
|
||||||
expect(".gitignore").to have_file_content <<~END
|
expect(".gitignore").to have_file_content <<-END
|
||||||
/db/*.sqlite
|
/db/*.sqlite
|
||||||
/public/assets*
|
/public/assets*
|
||||||
/tmp
|
/tmp
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
END
|
END
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -149,7 +153,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
"create db/schema.sql"
|
"create db/schema.sql"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami new #{project} --database=mysql", output
|
run_cmd "hanami new #{project} --database=mysql", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
|
@ -202,9 +206,11 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
#
|
#
|
||||||
# .gitignore
|
# .gitignore
|
||||||
#
|
#
|
||||||
expect(".gitignore").to have_file_content <<~END
|
expect(".gitignore").to have_file_content <<-END
|
||||||
/public/assets*
|
/public/assets*
|
||||||
/tmp
|
/tmp
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
END
|
END
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -214,7 +220,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
it "returns error" do
|
it "returns error" do
|
||||||
output = "`' is not a valid database engine"
|
output = "`' is not a valid database engine"
|
||||||
|
|
||||||
run_command "hanami new bookshelf --database=", output, exit_status: 1
|
run_cmd "hanami new bookshelf --database=", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end # missing
|
end # missing
|
||||||
|
|
||||||
|
@ -222,7 +228,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
it "returns error" do
|
it "returns error" do
|
||||||
output = "`foo' is not a valid database engine"
|
output = "`foo' is not a valid database engine"
|
||||||
|
|
||||||
run_command "hanami new bookshelf --database=foo", output, exit_status: 1
|
run_cmd "hanami new bookshelf --database=foo", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end # unknown
|
end # unknown
|
||||||
end # database
|
end # database
|
||||||
|
|
|
@ -5,23 +5,22 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
it "generates project" do
|
it "generates project" do
|
||||||
project = "bookshelf_hanami_head"
|
project = "bookshelf_hanami_head"
|
||||||
|
|
||||||
run_command "hanami new #{project} --hanami-head"
|
run_cmd "hanami new #{project} --hanami-head"
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
# Gemfile
|
# Gemfile
|
||||||
#
|
#
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-utils', require: false, git: 'https://github.com/hanami/utils.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-utils', require: false, git: 'https://github.com/hanami/utils.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-validations', require: false, git: 'https://github.com/hanami/validations.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-validations', require: false, git: 'https://github.com/hanami/validations.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-router', require: false, git: 'https://github.com/hanami/router.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-router', require: false, git: 'https://github.com/hanami/router.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-controller', require: false, git: 'https://github.com/hanami/controller.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-controller', require: false, git: 'https://github.com/hanami/controller.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-view', require: false, git: 'https://github.com/hanami/view.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-view', require: false, git: 'https://github.com/hanami/view.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-helpers', require: false, git: 'https://github.com/hanami/helpers.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-helpers', require: false, git: 'https://github.com/hanami/helpers.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-mailer', require: false, git: 'https://github.com/hanami/mailer.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-mailer', require: false, git: 'https://github.com/hanami/mailer.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-cli', require: false, git: 'https://github.com/hanami/cli.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-assets', require: false, git: 'https://github.com/hanami/assets.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-assets', require: false, git: 'https://github.com/hanami/assets.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami-model', require: false, git: 'https://github.com/hanami/model.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami-model', require: false, git: 'https://github.com/hanami/model.git', branch: 'develop'})
|
expect('Gemfile').to have_file_content(%r{gem 'hanami', git: 'https://github.com/hanami/hanami.git', branch: 'develop'})
|
||||||
expect("Gemfile").to have_file_content(%r{gem 'hanami', git: 'https://github.com/hanami/hanami.git', branch: 'develop'})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # hanami-head
|
end # hanami-head
|
||||||
|
|
|
@ -9,7 +9,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
"create apps/web/templates/application.html.erb"
|
"create apps/web/templates/application.html.erb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami new #{project} --template=erb", output
|
run_cmd "hanami new #{project} --template=erb", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
|
@ -43,7 +43,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
"create apps/web/templates/application.html.haml"
|
"create apps/web/templates/application.html.haml"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami new #{project} --template=haml", output
|
run_cmd "hanami new #{project} --template=haml", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
|
@ -74,7 +74,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
"create apps/web/templates/application.html.slim"
|
"create apps/web/templates/application.html.slim"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami new #{project} --template=slim", output
|
run_cmd "hanami new #{project} --template=slim", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
|
@ -103,7 +103,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
it "returns error" do
|
it "returns error" do
|
||||||
output = "`' is not a valid template engine. Please use one of: `erb', `haml', `slim'"
|
output = "`' is not a valid template engine. Please use one of: `erb', `haml', `slim'"
|
||||||
|
|
||||||
run_command "hanami new bookshelf --template=", output, exit_status: 1
|
run_cmd "hanami new bookshelf --template=", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end # missing
|
end # missing
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
it "returns error" do
|
it "returns error" do
|
||||||
output = "`foo' is not a valid template engine. Please use one of: `erb', `haml', `slim'"
|
output = "`foo' is not a valid template engine. Please use one of: `erb', `haml', `slim'"
|
||||||
|
|
||||||
run_command "hanami new bookshelf --template=foo", output, exit_status: 1
|
run_cmd "hanami new bookshelf --template=foo", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end # unknown
|
end # unknown
|
||||||
end # template
|
end # template
|
||||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
"create spec/web/views/application_layout_spec.rb"
|
"create spec/web/views/application_layout_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami new #{project} --test=minitest", output
|
run_cmd "hanami new #{project} --test=minitest", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
|
@ -79,7 +79,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
"create spec/web/views/application_layout_spec.rb"
|
"create spec/web/views/application_layout_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami new #{project} --test=rspec", output
|
run_cmd "hanami new #{project} --test=rspec", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
#
|
#
|
||||||
|
@ -259,7 +259,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
it "returns error" do
|
it "returns error" do
|
||||||
output = "`' is not a valid test framework. Please use one of: `rspec', `minitest'"
|
output = "`' is not a valid test framework. Please use one of: `rspec', `minitest'"
|
||||||
|
|
||||||
run_command "hanami new bookshelf --test=", output, exit_status: 1
|
run_cmd "hanami new bookshelf --test=", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end # missing
|
end # missing
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
it "returns error" do
|
it "returns error" do
|
||||||
output = "`foo' is not a valid test framework. Please use one of: `rspec', `minitest'"
|
output = "`foo' is not a valid test framework. Please use one of: `rspec', `minitest'"
|
||||||
|
|
||||||
run_command "hanami new bookshelf --test=foo", output, exit_status: 1
|
run_cmd "hanami new bookshelf --test=foo", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end # unknown
|
end # unknown
|
||||||
end # test
|
end # test
|
||||||
|
|
|
@ -50,11 +50,11 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
append .env.test
|
append .env.test
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami new #{project}", output
|
run_cmd "hanami new #{project}", output
|
||||||
|
|
||||||
within_project_directory(project) do
|
within_project_directory(project) do
|
||||||
# Assert it's an initialized Git repository
|
# Assert it's an initialized Git repository
|
||||||
run_command "git status", "On branch master"
|
run_cmd "git status", "On branch master"
|
||||||
|
|
||||||
#
|
#
|
||||||
# .hanamirc
|
# .hanamirc
|
||||||
|
@ -117,42 +117,42 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
% HANAMI_ENV=test bundle exec hanami db prepare
|
% HANAMI_ENV=test bundle exec hanami db prepare
|
||||||
```
|
```
|
||||||
|
|
||||||
Explore Hanami [guides](http://hanamirb.org/guides/), [API docs](http://docs.hanamirb.org/#{Hanami::VERSION}/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
|
Explore Hanami [guides](https://guides.hanamirb.org/), [API docs](http://docs.hanamirb.org/#{Hanami::VERSION}/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
|
||||||
END
|
END
|
||||||
|
|
||||||
#
|
#
|
||||||
# Gemfile
|
# Gemfile
|
||||||
#
|
#
|
||||||
if Platform.match?(engine: :ruby)
|
if Platform.match?(engine: :ruby)
|
||||||
expect("Gemfile").to have_file_content <<~END
|
expect('Gemfile').to have_file_content <<-END
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
gem 'hanami', '#{Hanami::Version.gem_requirement}'
|
gem 'hanami', '#{Hanami::Version.gem_requirement}'
|
||||||
gem 'hanami-model', '~> 1.3'
|
gem 'hanami-model', '~> 1.3'
|
||||||
|
|
||||||
gem 'sqlite3'
|
gem 'sqlite3'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# Code reloading
|
# Code reloading
|
||||||
# See: http://hanamirb.org/guides/projects/code-reloading
|
# See: https://guides.hanamirb.org/projects/code-reloading
|
||||||
gem 'shotgun', platforms: :ruby
|
gem 'shotgun', platforms: :ruby
|
||||||
gem 'hanami-webconsole'
|
gem 'hanami-webconsole'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test, :development do
|
group :test, :development do
|
||||||
gem 'dotenv', '~> 2.4'
|
gem 'dotenv', '~> 2.4'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
gem 'capybara'
|
gem 'capybara'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
# gem 'puma'
|
# gem 'puma'
|
||||||
end
|
end
|
||||||
END
|
END
|
||||||
end
|
end
|
||||||
|
|
||||||
if Platform.match?(engine: :jruby)
|
if Platform.match?(engine: :jruby)
|
||||||
|
@ -200,57 +200,57 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
#
|
#
|
||||||
# config/environment.rb
|
# config/environment.rb
|
||||||
#
|
#
|
||||||
expect("config/environment.rb").to have_file_content <<~END
|
expect('config/environment.rb').to have_file_content <<-END
|
||||||
require 'bundler/setup'
|
require 'bundler/setup'
|
||||||
require 'hanami/setup'
|
require 'hanami/setup'
|
||||||
require 'hanami/model'
|
require 'hanami/model'
|
||||||
require_relative '../lib/#{project}'
|
require_relative '../lib/#{project}'
|
||||||
require_relative '../apps/web/application'
|
require_relative '../apps/web/application'
|
||||||
|
|
||||||
Hanami.configure do
|
Hanami.configure do
|
||||||
mount Web::Application, at: '/'
|
mount Web::Application, at: '/'
|
||||||
|
|
||||||
model do
|
model do
|
||||||
##
|
##
|
||||||
# Database adapter
|
# Database adapter
|
||||||
#
|
#
|
||||||
# Available options:
|
# Available options:
|
||||||
#
|
#
|
||||||
# * SQL adapter
|
# * SQL adapter
|
||||||
# adapter :sql, 'sqlite://db/#{project}_development.sqlite3'
|
# adapter :sql, 'sqlite://db/#{project}_development.sqlite3'
|
||||||
# adapter :sql, 'postgresql://localhost/#{project}_development'
|
# adapter :sql, 'postgresql://localhost/#{project}_development'
|
||||||
# adapter :sql, 'mysql://localhost/#{project}_development'
|
# adapter :sql, 'mysql://localhost/#{project}_development'
|
||||||
#
|
#
|
||||||
adapter :sql, ENV.fetch('DATABASE_URL')
|
adapter :sql, ENV.fetch('DATABASE_URL')
|
||||||
|
|
||||||
##
|
##
|
||||||
# Migrations
|
# Migrations
|
||||||
#
|
#
|
||||||
migrations 'db/migrations'
|
migrations 'db/migrations'
|
||||||
schema 'db/schema.sql'
|
schema 'db/schema.sql'
|
||||||
end
|
end
|
||||||
|
|
||||||
mailer do
|
mailer do
|
||||||
root 'lib/#{project}/mailers'
|
root 'lib/#{project}/mailers'
|
||||||
|
|
||||||
# See http://hanamirb.org/guides/mailers/delivery
|
# See https://guides.hanamirb.org/mailers/delivery
|
||||||
delivery :test
|
delivery :test
|
||||||
end
|
end
|
||||||
|
|
||||||
environment :development do
|
environment :development do
|
||||||
# See: http://hanamirb.org/guides/projects/logging
|
# See: https://guides.hanamirb.org/projects/logging
|
||||||
logger level: :debug
|
logger level: :debug
|
||||||
end
|
end
|
||||||
|
|
||||||
environment :production do
|
environment :production do
|
||||||
logger level: :info, formatter: :json, filter: []
|
logger level: :info, formatter: :json, filter: []
|
||||||
|
|
||||||
mailer do
|
mailer do
|
||||||
delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
|
delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
END
|
END
|
||||||
|
|
||||||
project_module = Hanami::Utils::String.new(project).classify
|
project_module = Hanami::Utils::String.new(project).classify
|
||||||
#
|
#
|
||||||
|
@ -451,354 +451,343 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
#
|
#
|
||||||
# .gitignore
|
# .gitignore
|
||||||
#
|
#
|
||||||
expect(".gitignore").to have_file_content <<~END
|
expect(".gitignore").to have_file_content <<-END
|
||||||
/db/*.sqlite
|
/db/*.sqlite
|
||||||
/public/assets*
|
/public/assets*
|
||||||
/tmp
|
/tmp
|
||||||
END
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
END
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/application.rb
|
# apps/web/application.rb
|
||||||
#
|
#
|
||||||
expect("apps/web/application.rb").to have_file_content <<~END
|
expect("apps/web/application.rb").to have_file_content <<-END
|
||||||
require 'hanami/helpers'
|
require 'hanami/helpers'
|
||||||
require 'hanami/assets'
|
require 'hanami/assets'
|
||||||
|
|
||||||
module Web
|
module Web
|
||||||
class Application < Hanami::Application
|
class Application < Hanami::Application
|
||||||
configure do
|
configure do
|
||||||
##
|
##
|
||||||
# BASIC
|
# BASIC
|
||||||
#
|
#
|
||||||
|
|
||||||
# Define the root path of this application.
|
# Define the root path of this application.
|
||||||
# All paths specified in this configuration are relative to path below.
|
# All paths specified in this configuration are relative to path below.
|
||||||
#
|
#
|
||||||
root __dir__
|
root __dir__
|
||||||
|
|
||||||
# Relative load paths where this application will recursively load the
|
# Relative load paths where this application will recursively load the
|
||||||
# code.
|
# code.
|
||||||
#
|
#
|
||||||
# When you add new directories, remember to add them here.
|
# When you add new directories, remember to add them here.
|
||||||
#
|
#
|
||||||
load_paths << [
|
load_paths << [
|
||||||
'controllers',
|
'controllers',
|
||||||
'views'
|
'views'
|
||||||
]
|
]
|
||||||
|
|
||||||
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
||||||
# Defaults to true.
|
# Defaults to true.
|
||||||
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
||||||
#
|
#
|
||||||
# handle_exceptions true
|
# handle_exceptions true
|
||||||
|
|
||||||
##
|
##
|
||||||
# HTTP
|
# HTTP
|
||||||
#
|
#
|
||||||
|
|
||||||
# Routes definitions for this application
|
# Routes definitions for this application
|
||||||
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
||||||
#
|
#
|
||||||
routes 'config/routes'
|
routes 'config/routes'
|
||||||
|
|
||||||
# URI scheme used by the routing system to generate absolute URLs
|
# URI scheme used by the routing system to generate absolute URLs
|
||||||
# Defaults to "http"
|
# Defaults to "http"
|
||||||
#
|
#
|
||||||
# scheme 'https'
|
# scheme 'https'
|
||||||
|
|
||||||
# URI host used by the routing system to generate absolute URLs
|
# URI host used by the routing system to generate absolute URLs
|
||||||
# Defaults to "localhost"
|
# Defaults to "localhost"
|
||||||
#
|
#
|
||||||
# host 'example.org'
|
# host 'example.org'
|
||||||
|
|
||||||
# URI port used by the routing system to generate absolute URLs
|
# URI port used by the routing system to generate absolute URLs
|
||||||
# Argument: An object coercible to integer, defaults to 80 if the scheme
|
# Argument: An object coercible to integer, defaults to 80 if the scheme
|
||||||
# is http and 443 if it's https
|
# is http and 443 if it's https
|
||||||
#
|
#
|
||||||
# This should only be configured if app listens to non-standard ports
|
# This should only be configured if app listens to non-standard ports
|
||||||
#
|
#
|
||||||
# port 443
|
# port 443
|
||||||
|
|
||||||
# Enable cookies
|
# Enable cookies
|
||||||
# Argument: boolean to toggle the feature
|
# Argument: boolean to toggle the feature
|
||||||
# A Hash with options
|
# A Hash with options
|
||||||
#
|
#
|
||||||
# Options:
|
# Options:
|
||||||
# :domain - The domain (String - nil by default, not required)
|
# :domain - The domain (String - nil by default, not required)
|
||||||
# :path - Restrict cookies to a relative URI
|
# :path - Restrict cookies to a relative URI
|
||||||
# (String - nil by default)
|
# (String - nil by default)
|
||||||
# :max_age - Cookies expiration expressed in seconds
|
# :max_age - Cookies expiration expressed in seconds
|
||||||
# (Integer - nil by default)
|
# (Integer - nil by default)
|
||||||
# :secure - Restrict cookies to secure connections
|
# :secure - Restrict cookies to secure connections
|
||||||
# (Boolean - Automatically true when using HTTPS)
|
# (Boolean - Automatically true when using HTTPS)
|
||||||
# See #scheme and #ssl?
|
# See #scheme and #ssl?
|
||||||
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
||||||
#
|
#
|
||||||
# cookies true
|
# cookies true
|
||||||
# or
|
# or
|
||||||
# cookies max_age: 300
|
# cookies max_age: 300
|
||||||
|
|
||||||
# Enable sessions
|
# Enable sessions
|
||||||
# Argument: Symbol the Rack session adapter
|
# Argument: Symbol the Rack session adapter
|
||||||
# A Hash with options
|
# A Hash with options
|
||||||
#
|
#
|
||||||
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
||||||
#
|
#
|
||||||
# sessions :cookie, secret: ENV['WEB_SESSIONS_SECRET']
|
# sessions :cookie, secret: ENV['WEB_SESSIONS_SECRET']
|
||||||
|
|
||||||
# Configure Rack middleware for this application
|
# Configure Rack middleware for this application
|
||||||
#
|
#
|
||||||
# middleware.use Rack::Protection
|
# middleware.use Rack::Protection
|
||||||
|
|
||||||
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
||||||
# Argument: A symbol representation of a mime type, defaults to :html
|
# Argument: A symbol representation of a mime type, defaults to :html
|
||||||
#
|
#
|
||||||
# default_request_format :html
|
# default_request_format :html
|
||||||
|
|
||||||
# Default format for responses that don't consider the request format
|
# Default format for responses that don't consider the request format
|
||||||
# Argument: A symbol representation of a mime type, defaults to :html
|
# Argument: A symbol representation of a mime type, defaults to :html
|
||||||
#
|
#
|
||||||
# default_response_format :html
|
# default_response_format :html
|
||||||
|
|
||||||
# HTTP Body parsers
|
##
|
||||||
# Parse non GET responses body for a specific mime type
|
# TEMPLATES
|
||||||
# Argument: Symbol, which represent the format of the mime type
|
#
|
||||||
# (only `:json` is supported)
|
|
||||||
# Object, the parser
|
|
||||||
#
|
|
||||||
# body_parsers :json
|
|
||||||
|
|
||||||
# When it's true and the router receives a non-encrypted request (http),
|
# The layout to be used by all views
|
||||||
# it redirects to the secure equivalent (https). Disabled by default.
|
#
|
||||||
#
|
layout :application # It will load Web::Views::ApplicationLayout
|
||||||
# force_ssl true
|
|
||||||
|
|
||||||
##
|
# The relative path to templates
|
||||||
# TEMPLATES
|
#
|
||||||
#
|
templates 'templates'
|
||||||
|
|
||||||
# The layout to be used by all views
|
##
|
||||||
#
|
# ASSETS
|
||||||
layout :application # It will load Web::Views::ApplicationLayout
|
#
|
||||||
|
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
|
||||||
|
|
||||||
# The relative path to templates
|
# Stylesheet compressor
|
||||||
#
|
#
|
||||||
templates 'templates'
|
# 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
|
||||||
# ASSETS
|
#
|
||||||
#
|
sources << [
|
||||||
assets do
|
'assets'
|
||||||
# JavaScript compressor
|
]
|
||||||
#
|
end
|
||||||
# Supported engines:
|
|
||||||
#
|
|
||||||
# * :builtin
|
|
||||||
# * :uglifier
|
|
||||||
# * :yui
|
|
||||||
# * :closure
|
|
||||||
#
|
|
||||||
# See: http://hanamirb.org/guides/assets/compressors
|
|
||||||
#
|
|
||||||
# In order to skip JavaScript compression comment the following line
|
|
||||||
javascript_compressor :builtin
|
|
||||||
|
|
||||||
# Stylesheet compressor
|
##
|
||||||
#
|
# SECURITY
|
||||||
# Supported engines:
|
#
|
||||||
#
|
|
||||||
# * :builtin
|
|
||||||
# * :yui
|
|
||||||
# * :sass
|
|
||||||
#
|
|
||||||
# See: http://hanamirb.org/guides/assets/compressors
|
|
||||||
#
|
|
||||||
# In order to skip stylesheet compression comment the following line
|
|
||||||
stylesheet_compressor :builtin
|
|
||||||
|
|
||||||
# Specify sources for assets
|
# X-Frame-Options is a HTTP header supported by modern browsers.
|
||||||
#
|
# It determines if a web page can or cannot be included via <frame> and
|
||||||
sources << [
|
# <iframe> tags by untrusted domains.
|
||||||
'assets'
|
#
|
||||||
]
|
# Web applications can send this header to prevent Clickjacking attacks.
|
||||||
end
|
#
|
||||||
|
# Read more at:
|
||||||
|
#
|
||||||
|
# * https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
|
||||||
|
# * https://www.owasp.org/index.php/Clickjacking
|
||||||
|
#
|
||||||
|
security.x_frame_options 'DENY'
|
||||||
|
|
||||||
##
|
# X-Content-Type-Options prevents browsers from interpreting files as
|
||||||
# SECURITY
|
# something else than declared by the content type in the HTTP headers.
|
||||||
#
|
#
|
||||||
|
# Read more at:
|
||||||
|
#
|
||||||
|
# * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-Content-Type-Options
|
||||||
|
# * https://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx
|
||||||
|
# * https://blogs.msdn.microsoft.com/ie/2008/09/02/ie8-security-part-vi-beta-2-update
|
||||||
|
#
|
||||||
|
security.x_content_type_options 'nosniff'
|
||||||
|
|
||||||
# X-Frame-Options is a HTTP header supported by modern browsers.
|
# X-XSS-Protection is a HTTP header to determine the behavior of the
|
||||||
# It determines if a web page can or cannot be included via <frame> and
|
# browser in case an XSS attack is detected.
|
||||||
# <iframe> tags by untrusted domains.
|
#
|
||||||
#
|
# Read more at:
|
||||||
# Web applications can send this header to prevent Clickjacking attacks.
|
#
|
||||||
#
|
# * https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
|
||||||
# Read more at:
|
# * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-XSS-Protection
|
||||||
#
|
#
|
||||||
# * https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
|
security.x_xss_protection '1; mode=block'
|
||||||
# * https://www.owasp.org/index.php/Clickjacking
|
|
||||||
#
|
|
||||||
security.x_frame_options 'DENY'
|
|
||||||
|
|
||||||
# X-Content-Type-Options prevents browsers from interpreting files as
|
# Content-Security-Policy (CSP) is a HTTP header supported by modern
|
||||||
# something else than declared by the content type in the HTTP headers.
|
# browsers. It determines trusted sources of execution for dynamic
|
||||||
#
|
# contents (JavaScript) or other web related assets: stylesheets, images,
|
||||||
# Read more at:
|
# fonts, plugins, etc.
|
||||||
#
|
#
|
||||||
# * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-Content-Type-Options
|
# Web applications can send this header to mitigate Cross Site Scripting
|
||||||
# * https://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx
|
# (XSS) attacks.
|
||||||
# * https://blogs.msdn.microsoft.com/ie/2008/09/02/ie8-security-part-vi-beta-2-update
|
#
|
||||||
#
|
# The default value allows images, scripts, AJAX, fonts and CSS from the
|
||||||
security.x_content_type_options 'nosniff'
|
# same origin, and does not allow any other resources to load (eg object,
|
||||||
|
# frame, media, etc).
|
||||||
|
#
|
||||||
|
# Inline JavaScript is NOT allowed. To enable it, please use:
|
||||||
|
# "script-src 'unsafe-inline'".
|
||||||
|
#
|
||||||
|
# Content Security Policy introduction:
|
||||||
|
#
|
||||||
|
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||||
|
# * https://www.owasp.org/index.php/Content_Security_Policy
|
||||||
|
# * https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
|
||||||
|
#
|
||||||
|
# Inline and eval JavaScript risks:
|
||||||
|
#
|
||||||
|
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful
|
||||||
|
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#eval-too
|
||||||
|
#
|
||||||
|
# Content Security Policy usage:
|
||||||
|
#
|
||||||
|
# * http://content-security-policy.com/
|
||||||
|
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
|
||||||
|
#
|
||||||
|
# Content Security Policy references:
|
||||||
|
#
|
||||||
|
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives
|
||||||
|
#
|
||||||
|
security.content_security_policy %{
|
||||||
|
form-action 'self';
|
||||||
|
frame-ancestors 'self';
|
||||||
|
base-uri 'self';
|
||||||
|
default-src 'none';
|
||||||
|
script-src 'self';
|
||||||
|
connect-src 'self';
|
||||||
|
img-src 'self' https: data:;
|
||||||
|
style-src 'self' 'unsafe-inline' https:;
|
||||||
|
font-src 'self';
|
||||||
|
object-src 'none';
|
||||||
|
plugin-types application/pdf;
|
||||||
|
child-src 'self';
|
||||||
|
frame-src 'self';
|
||||||
|
media-src 'self'
|
||||||
|
}
|
||||||
|
|
||||||
# X-XSS-Protection is a HTTP header to determine the behavior of the
|
##
|
||||||
# browser in case an XSS attack is detected.
|
# FRAMEWORKS
|
||||||
#
|
#
|
||||||
# Read more at:
|
|
||||||
#
|
|
||||||
# * https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
|
|
||||||
# * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-XSS-Protection
|
|
||||||
#
|
|
||||||
security.x_xss_protection '1; mode=block'
|
|
||||||
|
|
||||||
# Content-Security-Policy (CSP) is a HTTP header supported by modern
|
# Configure the code that will yield each time Web::Action is included
|
||||||
# browsers. It determines trusted sources of execution for dynamic
|
# This is useful for sharing common functionality
|
||||||
# contents (JavaScript) or other web related assets: stylesheets, images,
|
#
|
||||||
# fonts, plugins, etc.
|
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
||||||
#
|
controller.prepare do
|
||||||
# Web applications can send this header to mitigate Cross Site Scripting
|
# include MyAuthentication # included in all the actions
|
||||||
# (XSS) attacks.
|
# before :authenticate! # run an authentication before callback
|
||||||
#
|
end
|
||||||
# The default value allows images, scripts, AJAX, fonts and CSS from the
|
|
||||||
# same origin, and does not allow any other resources to load (eg object,
|
|
||||||
# frame, media, etc).
|
|
||||||
#
|
|
||||||
# Inline JavaScript is NOT allowed. To enable it, please use:
|
|
||||||
# "script-src 'unsafe-inline'".
|
|
||||||
#
|
|
||||||
# Content Security Policy introduction:
|
|
||||||
#
|
|
||||||
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
|
||||||
# * https://www.owasp.org/index.php/Content_Security_Policy
|
|
||||||
# * https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
|
|
||||||
#
|
|
||||||
# Inline and eval JavaScript risks:
|
|
||||||
#
|
|
||||||
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful
|
|
||||||
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#eval-too
|
|
||||||
#
|
|
||||||
# Content Security Policy usage:
|
|
||||||
#
|
|
||||||
# * http://content-security-policy.com/
|
|
||||||
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
|
|
||||||
#
|
|
||||||
# Content Security Policy references:
|
|
||||||
#
|
|
||||||
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives
|
|
||||||
#
|
|
||||||
security.content_security_policy %{
|
|
||||||
form-action 'self';
|
|
||||||
frame-ancestors 'self';
|
|
||||||
base-uri 'self';
|
|
||||||
default-src 'none';
|
|
||||||
script-src 'self';
|
|
||||||
connect-src 'self';
|
|
||||||
img-src 'self' https: data:;
|
|
||||||
style-src 'self' 'unsafe-inline' https:;
|
|
||||||
font-src 'self';
|
|
||||||
object-src 'none';
|
|
||||||
plugin-types application/pdf;
|
|
||||||
child-src 'self';
|
|
||||||
frame-src 'self';
|
|
||||||
media-src 'self'
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
# Configure the code that will yield each time Web::View is included
|
||||||
# FRAMEWORKS
|
# This is useful for sharing common functionality
|
||||||
#
|
#
|
||||||
|
# See: http://www.rubydoc.info/gems/hanami-view#Configuration
|
||||||
|
view.prepare do
|
||||||
|
include Hanami::Helpers
|
||||||
|
include Web::Assets::Helpers
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Configure the code that will yield each time Web::Action is included
|
##
|
||||||
# This is useful for sharing common functionality
|
# DEVELOPMENT
|
||||||
#
|
#
|
||||||
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
configure :development do
|
||||||
controller.prepare do
|
# Don't handle exceptions, render the stack trace
|
||||||
# include MyAuthentication # included in all the actions
|
handle_exceptions false
|
||||||
# before :authenticate! # run an authentication before callback
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Configure the code that will yield each time Web::View is included
|
##
|
||||||
# This is useful for sharing common functionality
|
# TEST
|
||||||
#
|
#
|
||||||
# See: http://www.rubydoc.info/gems/hanami-view#Configuration
|
configure :test do
|
||||||
view.prepare do
|
# Don't handle exceptions, render the stack trace
|
||||||
include Hanami::Helpers
|
handle_exceptions false
|
||||||
include Web::Assets::Helpers
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# DEVELOPMENT
|
# PRODUCTION
|
||||||
#
|
#
|
||||||
configure :development do
|
configure :production do
|
||||||
# Don't handle exceptions, render the stack trace
|
# scheme 'https'
|
||||||
handle_exceptions false
|
# host 'example.org'
|
||||||
end
|
# port 443
|
||||||
|
|
||||||
##
|
assets do
|
||||||
# TEST
|
# Don't compile static assets in production mode (eg. Sass, ES6)
|
||||||
#
|
#
|
||||||
configure :test do
|
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
||||||
# Don't handle exceptions, render the stack trace
|
compile false
|
||||||
handle_exceptions false
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
# Use fingerprint file name for asset paths
|
||||||
# PRODUCTION
|
#
|
||||||
#
|
# See: https://guides.hanamirb.org/assets/overview
|
||||||
configure :production do
|
fingerprint true
|
||||||
# scheme 'https'
|
|
||||||
# host 'example.org'
|
|
||||||
# port 443
|
|
||||||
|
|
||||||
assets do
|
# Content Delivery Network (CDN)
|
||||||
# Don't compile static assets in production mode (eg. Sass, ES6)
|
#
|
||||||
#
|
# See: https://guides.hanamirb.org/assets/content-delivery-network
|
||||||
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
#
|
||||||
compile false
|
# scheme 'https'
|
||||||
|
# host 'cdn.example.org'
|
||||||
|
# port 443
|
||||||
|
|
||||||
# Use fingerprint file name for asset paths
|
# Subresource Integrity
|
||||||
#
|
#
|
||||||
# See: http://hanamirb.org/guides/assets/overview
|
# See: https://guides.hanamirb.org/assets/content-delivery-network/#subresource-integrity
|
||||||
fingerprint true
|
subresource_integrity :sha256
|
||||||
|
end
|
||||||
# Content Delivery Network (CDN)
|
end
|
||||||
#
|
end
|
||||||
# See: http://hanamirb.org/guides/assets/content-delivery-network
|
end
|
||||||
#
|
END
|
||||||
# scheme 'https'
|
|
||||||
# host 'cdn.example.org'
|
|
||||||
# port 443
|
|
||||||
|
|
||||||
# Subresource Integrity
|
|
||||||
#
|
|
||||||
# See: http://hanamirb.org/guides/assets/content-delivery-network/#subresource-integrity
|
|
||||||
subresource_integrity :sha256
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
END
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/config/routes.rb
|
# apps/web/config/routes.rb
|
||||||
#
|
#
|
||||||
expect("apps/web/config/routes.rb").to have_file_content <<~END
|
expect("apps/web/config/routes.rb").to have_file_content <<-END
|
||||||
# Configure your routes here
|
# Configure your routes here
|
||||||
# See: http://hanamirb.org/guides/routing/overview/
|
# See: https://guides.hanamirb.org/routing/overview
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
|
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
|
||||||
END
|
END
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/web/views/application_layout.rb
|
# apps/web/views/application_layout.rb
|
||||||
|
@ -895,7 +884,7 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
|
|
||||||
it "generates project" do
|
it "generates project" do
|
||||||
cd(dir) do
|
cd(dir) do
|
||||||
run_command "hanami new ."
|
run_cmd "hanami new ."
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -927,41 +916,41 @@ RSpec.describe "hanami new", type: :integration do
|
||||||
Usage: "hanami new PROJECT"
|
Usage: "hanami new PROJECT"
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami new", output, exit_status: 1
|
run_cmd "hanami new", output, exit_status: 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints help message" do
|
it 'prints help message' do
|
||||||
output = <<~OUT
|
output = <<-OUT
|
||||||
Command:
|
Command:
|
||||||
hanami new
|
hanami new
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
hanami new PROJECT
|
hanami new PROJECT
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
Generate a new Hanami project
|
Generate a new Hanami project
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
PROJECT # REQUIRED The project name
|
PROJECT # REQUIRED The project name
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--database=VALUE, -d VALUE # Database (mysql/mysql2/postgresql/postgres/sqlite/sqlite3), default: "sqlite"
|
--database=VALUE, -d VALUE # Database (mysql/mysql2/postgresql/postgres/sqlite/sqlite3), default: "sqlite"
|
||||||
--application-name=VALUE # App name, default: "web"
|
--application-name=VALUE # App name, default: "web"
|
||||||
--application-base-url=VALUE # App base URL, default: "/"
|
--application-base-url=VALUE # App base URL, default: "/"
|
||||||
--template=VALUE # Template engine (erb/haml/slim), default: "erb"
|
--template=VALUE # Template engine (erb/haml/slim), default: "erb"
|
||||||
--test=VALUE # Project testing framework (rspec/minitest), default: "rspec"
|
--test=VALUE # Project testing framework (rspec/minitest), default: "rspec"
|
||||||
--[no-]hanami-head # Use Hanami HEAD (true/false), default: false
|
--[no-]hanami-head # Use Hanami HEAD (true/false), default: false
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
hanami new bookshelf # Basic usage
|
hanami new bookshelf # Basic usage
|
||||||
hanami new bookshelf --test=rspec # Setup RSpec testing framework
|
hanami new bookshelf --test=rspec # Setup RSpec testing framework
|
||||||
hanami new bookshelf --database=postgres # Setup Postgres database
|
hanami new bookshelf --database=postgres # Setup Postgres database
|
||||||
hanami new bookshelf --template=slim # Setup Slim template engine
|
hanami new bookshelf --template=slim # Setup Slim template engine
|
||||||
hanami new bookshelf --hanami-head # Use Hanami HEAD
|
hanami new bookshelf --hanami-head # Use Hanami HEAD
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami new --help", output
|
run_cmd 'hanami new --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
require "pathname"
|
require "pathname"
|
||||||
|
|
||||||
RSpec.describe "CLI plugins", type: :integration do
|
RSpec.describe "CLI plugins", type: :integration do
|
||||||
it "includes its commands in CLI output" do
|
xit "includes its commands in CLI output" do
|
||||||
with_project do
|
with_project do
|
||||||
bundle_exec "hanami"
|
bundle_exec "hanami"
|
||||||
expect(out).to include("hanami plugin [SUBCOMMAND]")
|
expect(out).to include("hanami plugin [SUBCOMMAND]")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "executes command from plugin" do
|
xit "executes command from plugin" do
|
||||||
with_project do
|
with_project do
|
||||||
bundle_exec "hanami plugin version"
|
bundle_exec "hanami plugin version"
|
||||||
expect(out).to include("v0.1.0")
|
expect(out).to include("v0.1.0")
|
||||||
|
@ -22,7 +22,7 @@ RSpec.describe "CLI plugins", type: :integration do
|
||||||
project = "bookshelf_without_gemfile"
|
project = "bookshelf_without_gemfile"
|
||||||
|
|
||||||
with_system_tmp_directory do
|
with_system_tmp_directory do
|
||||||
run_command_with_clean_env "hanami new #{project}"
|
run_cmd_with_clean_env "hanami new #{project}"
|
||||||
destination = Pathname.new(Dir.pwd).join(project)
|
destination = Pathname.new(Dir.pwd).join(project)
|
||||||
|
|
||||||
expect(destination).to exist
|
expect(destination).to exist
|
||||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe "hanami routes", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami routes --help", output
|
run_cmd 'hanami routes --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe "hanami server", type: :integration do
|
||||||
|
|
||||||
expect(page).to have_content("The web, with simplicity.")
|
expect(page).to have_content("The web, with simplicity.")
|
||||||
expect(page).to have_content("Hanami is Open Source Software for MVC web development with Ruby.")
|
expect(page).to have_content("Hanami is Open Source Software for MVC web development with Ruby.")
|
||||||
expect(page).to have_content("bundle exec hanami generate action web home#index --url=/")
|
expect(page).to have_content("bundle exec hanami generate action web 'home#index' --url=/")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ RSpec.describe "hanami server", type: :integration do
|
||||||
server do
|
server do
|
||||||
visit "/admin"
|
visit "/admin"
|
||||||
|
|
||||||
expect(page).to have_content("bundle exec hanami generate action admin home#index --url=/")
|
expect(page).to have_content("bundle exec hanami generate action admin 'home#index' --url=/")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -114,7 +114,7 @@ RSpec.describe "hanami server", type: :integration do
|
||||||
touch log
|
touch log
|
||||||
replace "config/environment.rb", "logger level: :debug", %(logger level: :debug, stream: "#{log}")
|
replace "config/environment.rb", "logger level: :debug", %(logger level: :debug, stream: "#{log}")
|
||||||
|
|
||||||
run_command "hanami generate action web home#index --url=/", []
|
run_cmd "hanami generate action web home#index --url=/", []
|
||||||
|
|
||||||
server do
|
server do
|
||||||
visit "/?ping=pong"
|
visit "/?ping=pong"
|
||||||
|
@ -132,7 +132,7 @@ RSpec.describe "hanami server", type: :integration do
|
||||||
touch log
|
touch log
|
||||||
replace "config/environment.rb", "logger level: :debug", %(logger level: :debug, stream: "#{log}")
|
replace "config/environment.rb", "logger level: :debug", %(logger level: :debug, stream: "#{log}")
|
||||||
|
|
||||||
run_command "hanami generate action web books#create --method=POST", []
|
run_cmd "hanami generate action web books#create --method=POST", []
|
||||||
|
|
||||||
server do
|
server do
|
||||||
post "/books", book: { title: "Functions" }
|
post "/books", book: { title: "Functions" }
|
||||||
|
@ -150,7 +150,7 @@ RSpec.describe "hanami server", type: :integration do
|
||||||
replace "config/environment.rb", "logger level: :debug", %(logger level: :debug, stream: "#{log}")
|
replace "config/environment.rb", "logger level: :debug", %(logger level: :debug, stream: "#{log}")
|
||||||
inject_line_after "config/environment.rb", "Hanami.configure", "require 'hanami/middleware/body_parser'\nmiddleware.use Hanami::Middleware::BodyParser, :json"
|
inject_line_after "config/environment.rb", "Hanami.configure", "require 'hanami/middleware/body_parser'\nmiddleware.use Hanami::Middleware::BodyParser, :json"
|
||||||
|
|
||||||
run_command "hanami generate action web books#create --method=POST", []
|
run_cmd "hanami generate action web books#create --method=POST", []
|
||||||
inject_line_after "apps/web/controllers/books/create.rb", "call", 'Hanami.logger.debug(request.env["CONTENT_TYPE"]);self.body = %({"status":"OK"})'
|
inject_line_after "apps/web/controllers/books/create.rb", "call", 'Hanami.logger.debug(request.env["CONTENT_TYPE"]);self.body = %({"status":"OK"})'
|
||||||
|
|
||||||
server do
|
server do
|
||||||
|
@ -529,36 +529,36 @@ RSpec.describe "hanami server", type: :integration do
|
||||||
|
|
||||||
it "prints help message" do
|
it "prints help message" do
|
||||||
with_project do
|
with_project do
|
||||||
output = <<~OUT
|
output = <<-OUT
|
||||||
Command:
|
Command:
|
||||||
hanami server
|
hanami server
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
hanami server
|
hanami server
|
||||||
|
|
||||||
Description:
|
Description:
|
||||||
Start Hanami server (only for development)
|
Start Hanami server (only for development)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--server=VALUE # Force a server engine (eg, webrick, puma, thin, etc..)
|
--server=VALUE # Force a server engine (eg, webrick, puma, thin, etc..)
|
||||||
--host=VALUE # The host address to bind to
|
--host=VALUE # The host address to bind to
|
||||||
--port=VALUE, -p VALUE # The port to run the server on
|
--port=VALUE, -p VALUE # The port to run the server on
|
||||||
--debug=VALUE # Turn on debug output
|
--debug=VALUE # Turn on debug output
|
||||||
--warn=VALUE # Turn on warnings
|
--warn=VALUE # Turn on warnings
|
||||||
--daemonize=VALUE # Daemonize the server
|
--daemonize=VALUE # Daemonize the server
|
||||||
--pid=VALUE # Path to write a pid file after daemonize
|
--pid=VALUE # Path to write a pid file after daemonize
|
||||||
--[no-]code-reloading # Code reloading, default: true
|
--[no-]code-reloading # Code reloading, default: true
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
hanami server # Basic usage (it uses the bundled server engine)
|
hanami server # Basic usage (it uses the bundled server engine)
|
||||||
hanami server --server=webrick # Force `webrick` server engine
|
hanami server --server=webrick # Force `webrick` server engine
|
||||||
hanami server --host=0.0.0.0 # Bind to a host
|
hanami server --host=0.0.0.0 # Bind to a host
|
||||||
hanami server --port=2306 # Bind to a port
|
hanami server --port=2306 # Bind to a port
|
||||||
hanami server --no-code-reloading # Disable code reloading
|
hanami server --no-code-reloading # Disable code reloading
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami server --help", output
|
run_cmd 'hanami server --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,25 +4,25 @@ RSpec.describe "hanami version", type: :integration do
|
||||||
context "within a project" do
|
context "within a project" do
|
||||||
it "prints current version" do
|
it "prints current version" do
|
||||||
with_project do
|
with_project do
|
||||||
run_command "hanami version", "v#{Hanami::VERSION}"
|
run_cmd 'hanami version', "v#{Hanami::VERSION}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints current version with v alias" do
|
it "prints current version with v alias" do
|
||||||
with_project do
|
with_project do
|
||||||
run_command "hanami v", "v#{Hanami::VERSION}"
|
run_cmd 'hanami v', "v#{Hanami::VERSION}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints current version with -v alias" do
|
it "prints current version with -v alias" do
|
||||||
with_project do
|
with_project do
|
||||||
run_command "hanami -v", "v#{Hanami::VERSION}"
|
run_cmd 'hanami -v', "v#{Hanami::VERSION}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints current version with --version alias" do
|
it "prints current version with --version alias" do
|
||||||
with_project do
|
with_project do
|
||||||
run_command "hanami --version", "v#{Hanami::VERSION}"
|
run_cmd 'hanami --version', "v#{Hanami::VERSION}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,26 +42,26 @@ RSpec.describe "hanami version", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami version --help", output
|
run_cmd 'hanami version --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "outside of a project" do
|
context "outside of a project" do
|
||||||
it "prints current version" do
|
it 'prints current version' do
|
||||||
run_command "hanami version", "v#{Hanami::VERSION}"
|
run_cmd 'hanami version', "v#{Hanami::VERSION}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints current version with v alias" do
|
it 'prints current version with v alias' do
|
||||||
run_command "hanami v", "v#{Hanami::VERSION}"
|
run_cmd 'hanami v', "v#{Hanami::VERSION}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints current version with -v alias" do
|
it 'prints current version with -v alias' do
|
||||||
run_command "hanami -v", "v#{Hanami::VERSION}"
|
run_cmd 'hanami -v', "v#{Hanami::VERSION}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints current version with --version alias" do
|
it 'prints current version with --version alias' do
|
||||||
run_command "hanami --version", "v#{Hanami::VERSION}"
|
run_cmd 'hanami --version', "v#{Hanami::VERSION}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "prints help message" do
|
it "prints help message" do
|
||||||
|
@ -79,7 +79,7 @@ RSpec.describe "hanami version", type: :integration do
|
||||||
--help, -h # Print this help
|
--help, -h # Print this help
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami version --help", output
|
run_cmd 'hanami version --help', output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -104,7 +104,7 @@ RSpec.describe "handle exceptions", type: :integration do
|
||||||
|
|
||||||
expect(last_response.status).to eq(500)
|
expect(last_response.status).to eq(500)
|
||||||
expect(last_response.body).to_not include("This is a custom template for 500 error")
|
expect(last_response.body).to_not include("This is a custom template for 500 error")
|
||||||
expect(last_response.body).to include("<h1>Boot Error</h1><p>Something went wrong while loading")
|
expect(last_response.body).to include("Error from custom template")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -209,7 +209,7 @@ RSpec.describe "handle exceptions", type: :integration do
|
||||||
|
|
||||||
expect(last_response.status).to eq(500)
|
expect(last_response.status).to eq(500)
|
||||||
expect(last_response.body).to_not include("This is a custom template for 500 error")
|
expect(last_response.body).to_not include("This is a custom template for 500 error")
|
||||||
expect(last_response.body).to include("<h1>Boot Error</h1><p>Something went wrong while loading")
|
expect(last_response.body).to include("Error from custom template")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
require "resolv-replace"
|
||||||
|
require "net/http"
|
||||||
|
require "uri"
|
||||||
|
|
||||||
|
RSpec.describe "mount applications", type: :integration do
|
||||||
|
before do
|
||||||
|
stub_dns_hosts("127.0.0.1 #{host} www.#{host} #{subdomain} localhost")
|
||||||
|
end
|
||||||
|
|
||||||
|
let(:host) { "bookshelf.test" }
|
||||||
|
let(:subdomain) { "beta.#{host}" }
|
||||||
|
|
||||||
|
context "with apps mounted with path" do
|
||||||
|
it "shows welcome page" do
|
||||||
|
with_project do
|
||||||
|
generate_host_middleware
|
||||||
|
generate "app admin"
|
||||||
|
generate "app beta"
|
||||||
|
|
||||||
|
replace "config/environment.rb", "Beta::Application", %( mount Beta::Application, at: "/", host: "#{subdomain}")
|
||||||
|
|
||||||
|
server do
|
||||||
|
# Web
|
||||||
|
visit "/"
|
||||||
|
expect(page).to have_content("bundle exec hanami generate action web 'home#index' --url=/")
|
||||||
|
|
||||||
|
# Admin
|
||||||
|
visit "/admin"
|
||||||
|
expect(page).to have_content("bundle exec hanami generate action admin 'home#index' --url=/")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when apps mounted with host: option" do
|
||||||
|
it "shows welcome page" do
|
||||||
|
with_project do
|
||||||
|
generate_host_middleware
|
||||||
|
generate "app admin"
|
||||||
|
generate "app beta"
|
||||||
|
|
||||||
|
replace "config/environment.rb", "Beta::Application", %( mount Beta::Application, at: "/", host: "#{subdomain}")
|
||||||
|
|
||||||
|
port = RSpec::Support::RandomPort.call
|
||||||
|
server(port: port) do
|
||||||
|
# Beta
|
||||||
|
response = raw_http_request("http://#{subdomain}:#{port}")
|
||||||
|
expect(response.body).to include("bundle exec hanami generate action beta 'home#index' --url=/")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def generate_host_middleware
|
||||||
|
unshift "config/environment.rb", 'require_relative "./middleware/host"'
|
||||||
|
|
||||||
|
inject_line_after "config/environment.rb", "Hanami.configure", <<-EOL
|
||||||
|
middleware.use Middleware::Host
|
||||||
|
EOL
|
||||||
|
|
||||||
|
write "config/middleware/host.rb", <<-EOF
|
||||||
|
require "uri"
|
||||||
|
|
||||||
|
module Middleware
|
||||||
|
class Host
|
||||||
|
def initialize(app)
|
||||||
|
@app = app
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
host = URI.parse(env["REQUEST_URI"]).host
|
||||||
|
env["SERVER_NAME"] = host
|
||||||
|
env["HTTP_HOST"] = host
|
||||||
|
env["HTTP_X_FORWARDED_HOST"] = host
|
||||||
|
|
||||||
|
@app.call(env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
|
||||||
|
def raw_http_request(uri)
|
||||||
|
Net::HTTP.get_response(URI.parse(uri))
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
RSpec.describe "Rake: default task", type: :integration do
|
RSpec.describe "Rake: default task", type: :integration do
|
||||||
context "with Minitest" do
|
context "with Minitest" do
|
||||||
it "runs tests" do
|
xit "runs tests" do
|
||||||
with_project("bookshelf", test: "minitest") do
|
with_project("bookshelf", test: "minitest") do
|
||||||
setup_model
|
setup_model
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe "force SSL", type: :integration do
|
||||||
with_project(project, server: :puma) do
|
with_project(project, server: :puma) do
|
||||||
generate "action web home#index --url=/"
|
generate "action web home#index --url=/"
|
||||||
|
|
||||||
replace "apps/web/application.rb", "# force_ssl true", "force_ssl true"
|
inject_line_after "apps/web/application.rb", "configure do", "force_ssl true"
|
||||||
|
|
||||||
RSpec::Support::Env["HANAMI_ENV"] = "production"
|
RSpec::Support::Env["HANAMI_ENV"] = "production"
|
||||||
RSpec::Support::Env["DATABASE_URL"] = "sqlite://#{Pathname.new('db').join('bookshelf.sqlite')}"
|
RSpec::Support::Env["DATABASE_URL"] = "sqlite://#{Pathname.new('db').join('bookshelf.sqlite')}"
|
||||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe "Sessions", type: :integration do
|
||||||
|
|
||||||
expect(page).to have_content("The web, with simplicity.")
|
expect(page).to have_content("The web, with simplicity.")
|
||||||
expect(page).to have_content("Hanami is Open Source Software for MVC web development with Ruby.")
|
expect(page).to have_content("Hanami is Open Source Software for MVC web development with Ruby.")
|
||||||
expect(page).to have_content("bundle exec hanami generate action web home#index --url=/")
|
expect(page).to have_content("bundle exec hanami generate action web 'home#index' --url=/")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
HANAMI_PORT=42
|
HANAMI_PORT=42
|
||||||
BAZ="yes"
|
BAZ="yes"
|
||||||
WAT="true"
|
WAT="true"
|
||||||
|
LOADED_ENV_FILE='.env.development'
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
LOADED_ENV_FILE='.env.development.local'
|
|
@ -0,0 +1 @@
|
||||||
|
GLOBAL_ENV_LOCAL='true'
|
|
@ -30,350 +30,337 @@ RSpec.shared_examples "a new app" do
|
||||||
append .env.test
|
append .env.test
|
||||||
OUT
|
OUT
|
||||||
|
|
||||||
run_command "hanami generate app #{input}", output
|
run_cmd "hanami generate app #{input}", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/<app>/application.rb
|
# apps/<app>/application.rb
|
||||||
#
|
#
|
||||||
expect("apps/#{app}/application.rb").to have_file_content <<~END
|
expect("apps/#{app}/application.rb").to have_file_content <<-END
|
||||||
require 'hanami/helpers'
|
require 'hanami/helpers'
|
||||||
require 'hanami/assets'
|
require 'hanami/assets'
|
||||||
|
|
||||||
module #{app_name}
|
module #{app_name}
|
||||||
class Application < Hanami::Application
|
class Application < Hanami::Application
|
||||||
configure do
|
configure do
|
||||||
##
|
##
|
||||||
# BASIC
|
# BASIC
|
||||||
#
|
#
|
||||||
|
|
||||||
# Define the root path of this application.
|
# Define the root path of this application.
|
||||||
# All paths specified in this configuration are relative to path below.
|
# All paths specified in this configuration are relative to path below.
|
||||||
#
|
#
|
||||||
root __dir__
|
root __dir__
|
||||||
|
|
||||||
# Relative load paths where this application will recursively load the
|
# Relative load paths where this application will recursively load the
|
||||||
# code.
|
# code.
|
||||||
#
|
#
|
||||||
# When you add new directories, remember to add them here.
|
# When you add new directories, remember to add them here.
|
||||||
#
|
#
|
||||||
load_paths << [
|
load_paths << [
|
||||||
'controllers',
|
'controllers',
|
||||||
'views'
|
'views'
|
||||||
]
|
]
|
||||||
|
|
||||||
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
||||||
# Defaults to true.
|
# Defaults to true.
|
||||||
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
||||||
#
|
#
|
||||||
# handle_exceptions true
|
# handle_exceptions true
|
||||||
|
|
||||||
##
|
##
|
||||||
# HTTP
|
# HTTP
|
||||||
#
|
#
|
||||||
|
|
||||||
# Routes definitions for this application
|
# Routes definitions for this application
|
||||||
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
||||||
#
|
#
|
||||||
routes 'config/routes'
|
routes 'config/routes'
|
||||||
|
|
||||||
# URI scheme used by the routing system to generate absolute URLs
|
# URI scheme used by the routing system to generate absolute URLs
|
||||||
# Defaults to "http"
|
# Defaults to "http"
|
||||||
#
|
#
|
||||||
# scheme 'https'
|
# scheme 'https'
|
||||||
|
|
||||||
# URI host used by the routing system to generate absolute URLs
|
# URI host used by the routing system to generate absolute URLs
|
||||||
# Defaults to "localhost"
|
# Defaults to "localhost"
|
||||||
#
|
#
|
||||||
# host 'example.org'
|
# host 'example.org'
|
||||||
|
|
||||||
# URI port used by the routing system to generate absolute URLs
|
# URI port used by the routing system to generate absolute URLs
|
||||||
# Argument: An object coercible to integer, defaults to 80 if the scheme
|
# Argument: An object coercible to integer, defaults to 80 if the scheme
|
||||||
# is http and 443 if it's https
|
# is http and 443 if it's https
|
||||||
#
|
#
|
||||||
# This should only be configured if app listens to non-standard ports
|
# This should only be configured if app listens to non-standard ports
|
||||||
#
|
#
|
||||||
# port 443
|
# port 443
|
||||||
|
|
||||||
# Enable cookies
|
# Enable cookies
|
||||||
# Argument: boolean to toggle the feature
|
# Argument: boolean to toggle the feature
|
||||||
# A Hash with options
|
# A Hash with options
|
||||||
#
|
#
|
||||||
# Options:
|
# Options:
|
||||||
# :domain - The domain (String - nil by default, not required)
|
# :domain - The domain (String - nil by default, not required)
|
||||||
# :path - Restrict cookies to a relative URI
|
# :path - Restrict cookies to a relative URI
|
||||||
# (String - nil by default)
|
# (String - nil by default)
|
||||||
# :max_age - Cookies expiration expressed in seconds
|
# :max_age - Cookies expiration expressed in seconds
|
||||||
# (Integer - nil by default)
|
# (Integer - nil by default)
|
||||||
# :secure - Restrict cookies to secure connections
|
# :secure - Restrict cookies to secure connections
|
||||||
# (Boolean - Automatically true when using HTTPS)
|
# (Boolean - Automatically true when using HTTPS)
|
||||||
# See #scheme and #ssl?
|
# See #scheme and #ssl?
|
||||||
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
||||||
#
|
#
|
||||||
# cookies true
|
# cookies true
|
||||||
# or
|
# or
|
||||||
# cookies max_age: 300
|
# cookies max_age: 300
|
||||||
|
|
||||||
# Enable sessions
|
# Enable sessions
|
||||||
# Argument: Symbol the Rack session adapter
|
# Argument: Symbol the Rack session adapter
|
||||||
# A Hash with options
|
# A Hash with options
|
||||||
#
|
#
|
||||||
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
||||||
#
|
#
|
||||||
# sessions :cookie, secret: ENV['#{app_upcase}_SESSIONS_SECRET']
|
# sessions :cookie, secret: ENV['#{app_upcase}_SESSIONS_SECRET']
|
||||||
|
|
||||||
# Configure Rack middleware for this application
|
# Configure Rack middleware for this application
|
||||||
#
|
#
|
||||||
# middleware.use Rack::Protection
|
# middleware.use Rack::Protection
|
||||||
|
|
||||||
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
||||||
# Argument: A symbol representation of a mime type, defaults to :html
|
# Argument: A symbol representation of a mime type, defaults to :html
|
||||||
#
|
#
|
||||||
# default_request_format :html
|
# default_request_format :html
|
||||||
|
|
||||||
# Default format for responses that don't consider the request format
|
# Default format for responses that don't consider the request format
|
||||||
# Argument: A symbol representation of a mime type, defaults to :html
|
# Argument: A symbol representation of a mime type, defaults to :html
|
||||||
#
|
#
|
||||||
# default_response_format :html
|
# default_response_format :html
|
||||||
|
|
||||||
# HTTP Body parsers
|
##
|
||||||
# Parse non GET responses body for a specific mime type
|
# TEMPLATES
|
||||||
# Argument: Symbol, which represent the format of the mime type
|
#
|
||||||
# (only `:json` is supported)
|
|
||||||
# Object, the parser
|
|
||||||
#
|
|
||||||
# body_parsers :json
|
|
||||||
|
|
||||||
# When it's true and the router receives a non-encrypted request (http),
|
# The layout to be used by all views
|
||||||
# it redirects to the secure equivalent (https). Disabled by default.
|
#
|
||||||
#
|
layout :application # It will load #{app_name}::Views::ApplicationLayout
|
||||||
# force_ssl true
|
|
||||||
|
|
||||||
##
|
# The relative path to templates
|
||||||
# TEMPLATES
|
#
|
||||||
#
|
templates 'templates'
|
||||||
|
|
||||||
# The layout to be used by all views
|
##
|
||||||
#
|
# ASSETS
|
||||||
layout :application # It will load #{app_name}::Views::ApplicationLayout
|
#
|
||||||
|
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
|
||||||
|
|
||||||
# The relative path to templates
|
# Stylesheet compressor
|
||||||
#
|
#
|
||||||
templates 'templates'
|
# 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
|
||||||
# ASSETS
|
#
|
||||||
#
|
sources << [
|
||||||
assets do
|
'assets'
|
||||||
# JavaScript compressor
|
]
|
||||||
#
|
end
|
||||||
# Supported engines:
|
|
||||||
#
|
|
||||||
# * :builtin
|
|
||||||
# * :uglifier
|
|
||||||
# * :yui
|
|
||||||
# * :closure
|
|
||||||
#
|
|
||||||
# See: http://hanamirb.org/guides/assets/compressors
|
|
||||||
#
|
|
||||||
# In order to skip JavaScript compression comment the following line
|
|
||||||
javascript_compressor :builtin
|
|
||||||
|
|
||||||
# Stylesheet compressor
|
##
|
||||||
#
|
# SECURITY
|
||||||
# Supported engines:
|
#
|
||||||
#
|
|
||||||
# * :builtin
|
|
||||||
# * :yui
|
|
||||||
# * :sass
|
|
||||||
#
|
|
||||||
# See: http://hanamirb.org/guides/assets/compressors
|
|
||||||
#
|
|
||||||
# In order to skip stylesheet compression comment the following line
|
|
||||||
stylesheet_compressor :builtin
|
|
||||||
|
|
||||||
# Specify sources for assets
|
# X-Frame-Options is a HTTP header supported by modern browsers.
|
||||||
#
|
# It determines if a web page can or cannot be included via <frame> and
|
||||||
sources << [
|
# <iframe> tags by untrusted domains.
|
||||||
'assets'
|
#
|
||||||
]
|
# Web applications can send this header to prevent Clickjacking attacks.
|
||||||
end
|
#
|
||||||
|
# Read more at:
|
||||||
|
#
|
||||||
|
# * https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
|
||||||
|
# * https://www.owasp.org/index.php/Clickjacking
|
||||||
|
#
|
||||||
|
security.x_frame_options 'DENY'
|
||||||
|
|
||||||
##
|
# X-Content-Type-Options prevents browsers from interpreting files as
|
||||||
# SECURITY
|
# something else than declared by the content type in the HTTP headers.
|
||||||
#
|
#
|
||||||
|
# Read more at:
|
||||||
|
#
|
||||||
|
# * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-Content-Type-Options
|
||||||
|
# * https://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx
|
||||||
|
# * https://blogs.msdn.microsoft.com/ie/2008/09/02/ie8-security-part-vi-beta-2-update
|
||||||
|
#
|
||||||
|
security.x_content_type_options 'nosniff'
|
||||||
|
|
||||||
# X-Frame-Options is a HTTP header supported by modern browsers.
|
# X-XSS-Protection is a HTTP header to determine the behavior of the
|
||||||
# It determines if a web page can or cannot be included via <frame> and
|
# browser in case an XSS attack is detected.
|
||||||
# <iframe> tags by untrusted domains.
|
#
|
||||||
#
|
# Read more at:
|
||||||
# Web applications can send this header to prevent Clickjacking attacks.
|
#
|
||||||
#
|
# * https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
|
||||||
# Read more at:
|
# * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-XSS-Protection
|
||||||
#
|
#
|
||||||
# * https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
|
security.x_xss_protection '1; mode=block'
|
||||||
# * https://www.owasp.org/index.php/Clickjacking
|
|
||||||
#
|
|
||||||
security.x_frame_options 'DENY'
|
|
||||||
|
|
||||||
# X-Content-Type-Options prevents browsers from interpreting files as
|
# Content-Security-Policy (CSP) is a HTTP header supported by modern
|
||||||
# something else than declared by the content type in the HTTP headers.
|
# browsers. It determines trusted sources of execution for dynamic
|
||||||
#
|
# contents (JavaScript) or other web related assets: stylesheets, images,
|
||||||
# Read more at:
|
# fonts, plugins, etc.
|
||||||
#
|
#
|
||||||
# * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-Content-Type-Options
|
# Web applications can send this header to mitigate Cross Site Scripting
|
||||||
# * https://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx
|
# (XSS) attacks.
|
||||||
# * https://blogs.msdn.microsoft.com/ie/2008/09/02/ie8-security-part-vi-beta-2-update
|
#
|
||||||
#
|
# The default value allows images, scripts, AJAX, fonts and CSS from the
|
||||||
security.x_content_type_options 'nosniff'
|
# same origin, and does not allow any other resources to load (eg object,
|
||||||
|
# frame, media, etc).
|
||||||
|
#
|
||||||
|
# Inline JavaScript is NOT allowed. To enable it, please use:
|
||||||
|
# "script-src 'unsafe-inline'".
|
||||||
|
#
|
||||||
|
# Content Security Policy introduction:
|
||||||
|
#
|
||||||
|
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||||
|
# * https://www.owasp.org/index.php/Content_Security_Policy
|
||||||
|
# * https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
|
||||||
|
#
|
||||||
|
# Inline and eval JavaScript risks:
|
||||||
|
#
|
||||||
|
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful
|
||||||
|
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#eval-too
|
||||||
|
#
|
||||||
|
# Content Security Policy usage:
|
||||||
|
#
|
||||||
|
# * http://content-security-policy.com/
|
||||||
|
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
|
||||||
|
#
|
||||||
|
# Content Security Policy references:
|
||||||
|
#
|
||||||
|
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives
|
||||||
|
#
|
||||||
|
security.content_security_policy %{
|
||||||
|
form-action 'self';
|
||||||
|
frame-ancestors 'self';
|
||||||
|
base-uri 'self';
|
||||||
|
default-src 'none';
|
||||||
|
script-src 'self';
|
||||||
|
connect-src 'self';
|
||||||
|
img-src 'self' https: data:;
|
||||||
|
style-src 'self' 'unsafe-inline' https:;
|
||||||
|
font-src 'self';
|
||||||
|
object-src 'none';
|
||||||
|
plugin-types application/pdf;
|
||||||
|
child-src 'self';
|
||||||
|
frame-src 'self';
|
||||||
|
media-src 'self'
|
||||||
|
}
|
||||||
|
|
||||||
# X-XSS-Protection is a HTTP header to determine the behavior of the
|
##
|
||||||
# browser in case an XSS attack is detected.
|
# FRAMEWORKS
|
||||||
#
|
#
|
||||||
# Read more at:
|
|
||||||
#
|
|
||||||
# * https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
|
|
||||||
# * https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#X-XSS-Protection
|
|
||||||
#
|
|
||||||
security.x_xss_protection '1; mode=block'
|
|
||||||
|
|
||||||
# Content-Security-Policy (CSP) is a HTTP header supported by modern
|
# Configure the code that will yield each time #{app_name}::Action is included
|
||||||
# browsers. It determines trusted sources of execution for dynamic
|
# This is useful for sharing common functionality
|
||||||
# contents (JavaScript) or other web related assets: stylesheets, images,
|
#
|
||||||
# fonts, plugins, etc.
|
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
||||||
#
|
controller.prepare do
|
||||||
# Web applications can send this header to mitigate Cross Site Scripting
|
# include MyAuthentication # included in all the actions
|
||||||
# (XSS) attacks.
|
# before :authenticate! # run an authentication before callback
|
||||||
#
|
end
|
||||||
# The default value allows images, scripts, AJAX, fonts and CSS from the
|
|
||||||
# same origin, and does not allow any other resources to load (eg object,
|
|
||||||
# frame, media, etc).
|
|
||||||
#
|
|
||||||
# Inline JavaScript is NOT allowed. To enable it, please use:
|
|
||||||
# "script-src 'unsafe-inline'".
|
|
||||||
#
|
|
||||||
# Content Security Policy introduction:
|
|
||||||
#
|
|
||||||
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
|
||||||
# * https://www.owasp.org/index.php/Content_Security_Policy
|
|
||||||
# * https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
|
|
||||||
#
|
|
||||||
# Inline and eval JavaScript risks:
|
|
||||||
#
|
|
||||||
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful
|
|
||||||
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#eval-too
|
|
||||||
#
|
|
||||||
# Content Security Policy usage:
|
|
||||||
#
|
|
||||||
# * http://content-security-policy.com/
|
|
||||||
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
|
|
||||||
#
|
|
||||||
# Content Security Policy references:
|
|
||||||
#
|
|
||||||
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives
|
|
||||||
#
|
|
||||||
security.content_security_policy %{
|
|
||||||
form-action 'self';
|
|
||||||
frame-ancestors 'self';
|
|
||||||
base-uri 'self';
|
|
||||||
default-src 'none';
|
|
||||||
script-src 'self';
|
|
||||||
connect-src 'self';
|
|
||||||
img-src 'self' https: data:;
|
|
||||||
style-src 'self' 'unsafe-inline' https:;
|
|
||||||
font-src 'self';
|
|
||||||
object-src 'none';
|
|
||||||
plugin-types application/pdf;
|
|
||||||
child-src 'self';
|
|
||||||
frame-src 'self';
|
|
||||||
media-src 'self'
|
|
||||||
}
|
|
||||||
|
|
||||||
##
|
# Configure the code that will yield each time #{app_name}::View is included
|
||||||
# FRAMEWORKS
|
# This is useful for sharing common functionality
|
||||||
#
|
#
|
||||||
|
# See: http://www.rubydoc.info/gems/hanami-view#Configuration
|
||||||
|
view.prepare do
|
||||||
|
include Hanami::Helpers
|
||||||
|
include #{app_name}::Assets::Helpers
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Configure the code that will yield each time #{app_name}::Action is included
|
##
|
||||||
# This is useful for sharing common functionality
|
# DEVELOPMENT
|
||||||
#
|
#
|
||||||
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
configure :development do
|
||||||
controller.prepare do
|
# Don't handle exceptions, render the stack trace
|
||||||
# include MyAuthentication # included in all the actions
|
handle_exceptions false
|
||||||
# before :authenticate! # run an authentication before callback
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Configure the code that will yield each time #{app_name}::View is included
|
##
|
||||||
# This is useful for sharing common functionality
|
# TEST
|
||||||
#
|
#
|
||||||
# See: http://www.rubydoc.info/gems/hanami-view#Configuration
|
configure :test do
|
||||||
view.prepare do
|
# Don't handle exceptions, render the stack trace
|
||||||
include Hanami::Helpers
|
handle_exceptions false
|
||||||
include #{app_name}::Assets::Helpers
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# DEVELOPMENT
|
# PRODUCTION
|
||||||
#
|
#
|
||||||
configure :development do
|
configure :production do
|
||||||
# Don't handle exceptions, render the stack trace
|
# scheme 'https'
|
||||||
handle_exceptions false
|
# host 'example.org'
|
||||||
end
|
# port 443
|
||||||
|
|
||||||
##
|
assets do
|
||||||
# TEST
|
# Don't compile static assets in production mode (eg. Sass, ES6)
|
||||||
#
|
#
|
||||||
configure :test do
|
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
||||||
# Don't handle exceptions, render the stack trace
|
compile false
|
||||||
handle_exceptions false
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
# Use fingerprint file name for asset paths
|
||||||
# PRODUCTION
|
#
|
||||||
#
|
# See: https://guides.hanamirb.org/assets/overview
|
||||||
configure :production do
|
fingerprint true
|
||||||
# scheme 'https'
|
|
||||||
# host 'example.org'
|
|
||||||
# port 443
|
|
||||||
|
|
||||||
assets do
|
# Content Delivery Network (CDN)
|
||||||
# Don't compile static assets in production mode (eg. Sass, ES6)
|
#
|
||||||
#
|
# See: https://guides.hanamirb.org/assets/content-delivery-network
|
||||||
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
#
|
||||||
compile false
|
# scheme 'https'
|
||||||
|
# host 'cdn.example.org'
|
||||||
|
# port 443
|
||||||
|
|
||||||
# Use fingerprint file name for asset paths
|
# Subresource Integrity
|
||||||
#
|
#
|
||||||
# See: http://hanamirb.org/guides/assets/overview
|
# See: https://guides.hanamirb.org/assets/content-delivery-network/#subresource-integrity
|
||||||
fingerprint true
|
subresource_integrity :sha256
|
||||||
|
end
|
||||||
# Content Delivery Network (CDN)
|
end
|
||||||
#
|
end
|
||||||
# See: http://hanamirb.org/guides/assets/content-delivery-network
|
end
|
||||||
#
|
END
|
||||||
# scheme 'https'
|
|
||||||
# host 'cdn.example.org'
|
|
||||||
# port 443
|
|
||||||
|
|
||||||
# Subresource Integrity
|
|
||||||
#
|
|
||||||
# See: http://hanamirb.org/guides/assets/content-delivery-network/#subresource-integrity
|
|
||||||
subresource_integrity :sha256
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
END
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/<app>/config/routes.rb
|
# apps/<app>/config/routes.rb
|
||||||
#
|
#
|
||||||
expect("apps/#{app}/config/routes.rb").to have_file_content <<~END
|
expect("apps/#{app}/config/routes.rb").to have_file_content <<-END
|
||||||
# Configure your routes here
|
# Configure your routes here
|
||||||
# See: http://hanamirb.org/guides/routing/overview/
|
# See: https://guides.hanamirb.org/routing/overview
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
|
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
|
||||||
END
|
END
|
||||||
|
|
||||||
#
|
#
|
||||||
# apps/<app>/views/application_layout.rb
|
# apps/<app>/views/application_layout.rb
|
||||||
|
@ -431,59 +418,59 @@ RSpec.shared_examples "a new app" do
|
||||||
#
|
#
|
||||||
# config/environment.rb
|
# config/environment.rb
|
||||||
#
|
#
|
||||||
expect("config/environment.rb").to have_file_content <<~END
|
expect("config/environment.rb").to have_file_content <<-END
|
||||||
require 'bundler/setup'
|
require 'bundler/setup'
|
||||||
require 'hanami/setup'
|
require 'hanami/setup'
|
||||||
require 'hanami/model'
|
require 'hanami/model'
|
||||||
require_relative '../lib/#{project}'
|
require_relative '../lib/#{project}'
|
||||||
require_relative '../apps/web/application'
|
require_relative '../apps/web/application'
|
||||||
require_relative '../apps/#{app}/application'
|
require_relative '../apps/#{app}/application'
|
||||||
|
|
||||||
Hanami.configure do
|
Hanami.configure do
|
||||||
mount #{app_name}::Application, at: '/#{app}'
|
mount #{app_name}::Application, at: '/#{app}'
|
||||||
mount Web::Application, at: '/'
|
mount Web::Application, at: '/'
|
||||||
|
|
||||||
model do
|
model do
|
||||||
##
|
##
|
||||||
# Database adapter
|
# Database adapter
|
||||||
#
|
#
|
||||||
# Available options:
|
# Available options:
|
||||||
#
|
#
|
||||||
# * SQL adapter
|
# * SQL adapter
|
||||||
# adapter :sql, 'sqlite://db/#{project}_development.sqlite3'
|
# adapter :sql, 'sqlite://db/#{project}_development.sqlite3'
|
||||||
# adapter :sql, 'postgresql://localhost/#{project}_development'
|
# adapter :sql, 'postgresql://localhost/#{project}_development'
|
||||||
# adapter :sql, 'mysql://localhost/#{project}_development'
|
# adapter :sql, 'mysql://localhost/#{project}_development'
|
||||||
#
|
#
|
||||||
adapter :sql, ENV.fetch('DATABASE_URL')
|
adapter :sql, ENV.fetch('DATABASE_URL')
|
||||||
|
|
||||||
##
|
##
|
||||||
# Migrations
|
# Migrations
|
||||||
#
|
#
|
||||||
migrations 'db/migrations'
|
migrations 'db/migrations'
|
||||||
schema 'db/schema.sql'
|
schema 'db/schema.sql'
|
||||||
end
|
end
|
||||||
|
|
||||||
mailer do
|
mailer do
|
||||||
root 'lib/#{project}/mailers'
|
root 'lib/#{project}/mailers'
|
||||||
|
|
||||||
# See http://hanamirb.org/guides/mailers/delivery
|
# See https://guides.hanamirb.org/mailers/delivery
|
||||||
delivery :test
|
delivery :test
|
||||||
end
|
end
|
||||||
|
|
||||||
environment :development do
|
environment :development do
|
||||||
# See: http://hanamirb.org/guides/projects/logging
|
# See: https://guides.hanamirb.org/projects/logging
|
||||||
logger level: :debug
|
logger level: :debug
|
||||||
end
|
end
|
||||||
|
|
||||||
environment :production do
|
environment :production do
|
||||||
logger level: :info, formatter: :json, filter: []
|
logger level: :info, formatter: :json, filter: []
|
||||||
|
|
||||||
mailer do
|
mailer do
|
||||||
delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
|
delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
END
|
END
|
||||||
|
|
||||||
#
|
#
|
||||||
# .env.development
|
# .env.development
|
||||||
|
|
|
@ -9,7 +9,7 @@ RSpec.shared_examples "a new migration" do
|
||||||
project = "bookshelf_generate_migration_#{Random.rand(100_000_000)}"
|
project = "bookshelf_generate_migration_#{Random.rand(100_000_000)}"
|
||||||
|
|
||||||
with_project(project) do
|
with_project(project) do
|
||||||
run_command "hanami generate migration #{input}", migration
|
run_cmd "hanami generate migration #{input}", migration
|
||||||
|
|
||||||
#
|
#
|
||||||
# db/migrations/<timestamp>_<migration>.rb
|
# db/migrations/<timestamp>_<migration>.rb
|
||||||
|
|
|
@ -19,7 +19,7 @@ RSpec.shared_examples "a new model" do
|
||||||
"create spec/#{project}/repositories/#{model}_repository_spec.rb"
|
"create spec/#{project}/repositories/#{model}_repository_spec.rb"
|
||||||
]
|
]
|
||||||
|
|
||||||
run_command "hanami generate model #{input}", output
|
run_cmd "hanami generate model #{input}", output
|
||||||
|
|
||||||
#
|
#
|
||||||
# lib/<project>/entities/<model>.rb
|
# lib/<project>/entities/<model>.rb
|
||||||
|
|
|
@ -5,8 +5,8 @@ require "hanami/utils/string"
|
||||||
RSpec.shared_examples "a new project" do
|
RSpec.shared_examples "a new project" do
|
||||||
let(:project) { Hanami::Utils::String.new(input).underscore.to_s }
|
let(:project) { Hanami::Utils::String.new(input).underscore.to_s }
|
||||||
|
|
||||||
it "generates vanilla project" do
|
it 'generates vanilla project' do
|
||||||
run_command "hanami new #{input}"
|
run_cmd "hanami new #{input}"
|
||||||
|
|
||||||
[
|
[
|
||||||
"create lib/#{project}.rb",
|
"create lib/#{project}.rb",
|
||||||
|
@ -85,11 +85,13 @@ RSpec.shared_examples "a new project" do
|
||||||
#
|
#
|
||||||
# .gitignore
|
# .gitignore
|
||||||
#
|
#
|
||||||
expect(".gitignore").to have_file_content <<~END
|
expect(".gitignore").to have_file_content <<-END
|
||||||
/db/*.sqlite
|
/db/*.sqlite
|
||||||
/public/assets*
|
/public/assets*
|
||||||
/tmp
|
/tmp
|
||||||
END
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
END
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue