Merge branch 'develop' into unstable
This commit is contained in:
commit
c458489d18
|
@ -1,6 +1,6 @@
|
|||
name: ci
|
||||
|
||||
on:
|
||||
"on":
|
||||
push:
|
||||
paths:
|
||||
- ".github/workflows/ci.yml"
|
||||
|
@ -24,14 +24,12 @@ jobs:
|
|||
ruby:
|
||||
- "2.7"
|
||||
- "2.6"
|
||||
include:
|
||||
- ruby: "2.7"
|
||||
coverage: "true"
|
||||
env:
|
||||
COVERAGE: ${{matrix.coverage}}
|
||||
CI: true
|
||||
- "2.5"
|
||||
- "2.4"
|
||||
steps:
|
||||
- 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
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
|
@ -39,13 +37,7 @@ jobs:
|
|||
- name: Install latest bundler
|
||||
run: |
|
||||
gem install bundler --no-document
|
||||
bundle config set without 'tools benchmarks docs'
|
||||
- name: Bundle install
|
||||
run: bundle install --jobs 4 --retry 3
|
||||
- name: Run all tests
|
||||
run: bundle exec rake
|
||||
- name: Send test coverage report to codecov.io
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
token: ${{secrets.COVERAGE_TOKEN}}
|
||||
file: ./coverage/.resultset.json
|
||||
run: script/ci
|
||||
|
|
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 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
|
||||
### Added
|
||||
- [Luca Guidi] Automatically log body payload from body parsers
|
||||
|
@ -65,7 +90,7 @@ end
|
|||
|
||||
### Fixed
|
||||
- [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
|
||||
|
||||
### Fixed
|
||||
|
@ -182,7 +207,7 @@ end
|
|||
- [Luca Guidi] Make compatible with Rack 2.0 only
|
||||
- [Luca Guidi] Removed `logger` settings from Hanami applications
|
||||
- [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
|
||||
## Added
|
||||
|
@ -271,11 +296,11 @@ end
|
|||
|
||||
## v0.7.2 - 2016-02-09
|
||||
### 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
|
||||
### 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`
|
||||
|
||||
## v0.7.0 - 2016-01-22
|
||||
|
@ -410,7 +435,7 @@ end
|
|||
## v0.3.0 - 2015-03-23
|
||||
### Added
|
||||
- [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.
|
||||
- [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
|
||||
|
|
10
FEATURES.md
10
FEATURES.md
|
@ -5,6 +5,14 @@
|
|||
|
||||
## 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
|
||||
|
||||
- Default testing framework is RSpec
|
||||
|
@ -20,7 +28,7 @@
|
|||
- Unobtrusive JavaScript (UJS) (via `hanami-ujs` 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") { ... }`)
|
||||
- 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 }`)
|
||||
- Custom repository commands
|
||||
- Coloured logging
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright © 2014-2017 Luca Guidi
|
||||
Copyright © 2014-2021 Luca Guidi
|
||||
|
||||
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::Mailer**](https://github.com/hanami/mailer) - Mail for Ruby applications
|
||||
* [**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
|
||||
|
||||
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
|
||||
|
||||
[![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)
|
||||
[![Test Coverage](https://codecov.io/gh/hanami/hanami/branch/master/graph/badge.svg)](https://codecov.io/gh/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/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)
|
||||
[![Inline Docs](http://inch-ci.org/github/hanami/hanami.svg)](http://inch-ci.org/github/hanami/hanami)
|
||||
|
||||
## Installation
|
||||
|
||||
__Hanami__ supports Ruby (MRI) 2.5+
|
||||
__Hanami__ supports Ruby (MRI) 2.6+
|
||||
|
||||
```shell
|
||||
gem install hanami
|
||||
|
@ -137,4 +136,4 @@ Released under MIT License.
|
|||
|
||||
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 "hanami/cli/commands"
|
||||
|
||||
Bundler.require(*Hanami.bundler_groups) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
|
||||
Hanami::CLI.new(Hanami::CLI::Commands).call
|
||||
::Bundler.require(:plugins) if File.exist?(ENV["BUNDLE_GEMFILE"] || "Gemfile")
|
||||
Dry::CLI.new(Hanami::CLI::Commands).call
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "hanami/cli"
|
||||
require "dry/cli"
|
||||
require "ostruct"
|
||||
|
||||
module Hanami
|
||||
# Hanami CLI
|
||||
|
@ -55,7 +56,7 @@ module Hanami
|
|||
# @since 1.1.0
|
||||
# @api private
|
||||
module Commands
|
||||
extend Hanami::CLI::Registry
|
||||
extend Dry::CLI::Registry
|
||||
|
||||
require "hanami/cli/commands/command"
|
||||
require "hanami/cli/commands/server"
|
||||
|
|
|
@ -15,7 +15,7 @@ module Hanami
|
|||
# Abstract command
|
||||
#
|
||||
# @since 1.1.0
|
||||
class Command < Hanami::CLI::Command
|
||||
class Command < Dry::CLI::Command
|
||||
# @since 1.1.0
|
||||
# @api private
|
||||
def self.inherited(component)
|
||||
|
@ -70,22 +70,46 @@ module Hanami
|
|||
# @since 1.1.0
|
||||
# @api private
|
||||
def call(**options)
|
||||
<<<<<<< HEAD
|
||||
# FIXME: merge ENV vars (like HANAMI_ENV) into **options
|
||||
super(options)
|
||||
rescue StandardError => exception
|
||||
warn exception.message
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
# @since 1.1.0
|
||||
# @api private
|
||||
<<<<<<< HEAD
|
||||
def initialize(command_name:, out: $stdout, files: Utils::Files)
|
||||
super(command_name: command_name)
|
||||
|
||||
@out = out
|
||||
@files = files
|
||||
=======
|
||||
def initialize(out: $stdout, files: Utils::Files)
|
||||
@out = out
|
||||
@files = files
|
||||
@templates = Templates.new(self.class)
|
||||
>>>>>>> develop
|
||||
end
|
||||
|
||||
private
|
||||
|
|
16
script/ci
16
script/ci
|
@ -3,9 +3,9 @@ set -euo pipefail
|
|||
IFS=$'\n\t'
|
||||
|
||||
setup() {
|
||||
remove_coverage &&
|
||||
print_ruby_version &&
|
||||
install_gems
|
||||
remove_coverage
|
||||
print_ruby_version
|
||||
install_gems
|
||||
}
|
||||
|
||||
remove_coverage() {
|
||||
|
@ -73,11 +73,11 @@ upload_code_coverage() {
|
|||
}
|
||||
|
||||
main() {
|
||||
setup &&
|
||||
run_unit_tests &&
|
||||
run_isolation_tests &&
|
||||
run_code_quality_checks &&
|
||||
upload_code_coverage
|
||||
setup
|
||||
run_unit_tests
|
||||
run_isolation_tests
|
||||
run_integration_tests
|
||||
upload_code_coverage
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
@ -20,7 +20,7 @@ bundle_package() {
|
|||
}
|
||||
|
||||
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[@]}"
|
||||
do
|
||||
|
|
|
@ -3,7 +3,7 @@ set -euo pipefail
|
|||
IFS=$'\n\t'
|
||||
|
||||
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[@]}"
|
||||
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
|
||||
project = "bookshelf_serve_assets"
|
||||
|
||||
with_project(project, gems: ["sass"]) do
|
||||
with_project(project, gems: ['sassc']) do
|
||||
generate "action web home#index --url=/"
|
||||
|
||||
write "apps/web/assets/javascripts/application.css.sass", <<~EOF
|
||||
|
|
|
@ -45,6 +45,6 @@ RSpec.describe "body parsers", type: :integration do
|
|||
end
|
||||
|
||||
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
|
||||
|
|
|
@ -5,7 +5,7 @@ require "json"
|
|||
RSpec.describe "hanami assets", type: :integration do
|
||||
describe "precompile" do
|
||||
it "precompiles assets" do
|
||||
gems = %w[sass coffee-script]
|
||||
gems = %w[sassc coffee-script]
|
||||
|
||||
Platform.match do
|
||||
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
|
||||
OUT
|
||||
|
||||
run_command "hanami assets precompile --help", output
|
||||
run_cmd "hanami assets precompile --help", output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe "hanami assets", type: :integration do
|
|||
hanami assets precompile # Precompile assets for deployment
|
||||
OUT
|
||||
|
||||
run_command "hanami assets", output, exit_status: 1
|
||||
run_cmd "hanami assets", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,14 +64,14 @@ RSpec.describe "hanami console", type: :integration do
|
|||
xit "returns error when known engine isn't bundled" do
|
||||
with_project("bookshelf_console_irb", console: :irb) do
|
||||
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
|
||||
|
||||
it "returns error when unknown engine is requested" do
|
||||
with_project("bookshelf_console_irb", console: :irb) do
|
||||
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
|
||||
|
||||
|
@ -96,7 +96,7 @@ RSpec.describe "hanami console", type: :integration do
|
|||
hanami console --engine=pry # Force to use Pry
|
||||
OUT
|
||||
|
||||
run_command "hanami console --help", output
|
||||
run_cmd "hanami console --help", output
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
RSpec.describe "hanami db", type: :integration 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
|
||||
versions = generate_migrations
|
||||
|
||||
|
@ -26,6 +26,31 @@ RSpec.describe "hanami db", type: :integration do
|
|||
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
|
||||
with_project do
|
||||
output = <<~OUT
|
||||
|
@ -42,7 +67,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami db apply --help", output
|
||||
run_cmd "hanami db apply --help", output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami db console --help", output
|
||||
run_cmd "hanami db console --help", output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami db create --help", output
|
||||
run_cmd 'hanami db create --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,7 +47,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami db drop --help", output
|
||||
run_cmd 'hanami db drop --help', output
|
||||
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}
|
||||
]
|
||||
|
||||
run_command "hanami db drop --help", output
|
||||
run_cmd 'hanami db drop --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami db prepare --help", output
|
||||
run_cmd 'hanami db prepare --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,7 +50,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
hanami "db migrate"
|
||||
|
||||
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
|
||||
|
||||
|
@ -62,7 +62,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
hanami "db migrate"
|
||||
|
||||
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
|
||||
|
||||
|
@ -84,11 +84,12 @@ RSpec.describe "hanami db", type: :integration do
|
|||
Options:
|
||||
--help, -h # Print this help
|
||||
|
||||
Examples:
|
||||
hanami db rollback # Rollbacks latest migration
|
||||
hanami db rollback 2 # Rollbacks last two migrations
|
||||
OUT
|
||||
run_command "hanami db rollback --help", output
|
||||
Examples:
|
||||
hanami db rollback # Rollbacks latest migration
|
||||
hanami db rollback 2 # Rollbacks last two migrations
|
||||
OUT
|
||||
|
||||
run_cmd 'hanami db rollback --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami db version --help", output
|
||||
run_cmd 'hanami db version --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe "hanami db", type: :integration do
|
|||
hanami db version # Print the current migrated version
|
||||
OUT
|
||||
|
||||
run_command "hanami db", output, exit_status: 1
|
||||
run_cmd "hanami db", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
"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("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"
|
||||
]
|
||||
|
||||
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("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"
|
||||
]
|
||||
|
||||
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("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"
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy action", output, exit_status: 1
|
||||
run_cmd "hanami destroy action", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,7 +89,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
Usage: "hanami destroy action APP ACTION"
|
||||
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
|
||||
|
||||
|
@ -97,7 +97,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
with_project("bookshelf_generate_action_with_unknown_app") do
|
||||
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
|
||||
|
||||
|
@ -108,7 +108,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
please run `hanami routes' to know the existing actions.
|
||||
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
|
||||
|
||||
|
@ -136,7 +136,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
hanami destroy action admin users#index # Destroy from `admin` app
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy action --help", output
|
||||
run_cmd 'hanami destroy action --help', output
|
||||
end
|
||||
end
|
||||
end # action
|
||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
"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.development").to_not have_file_content(%r{ADMIN_SESSIONS_SECRET})
|
||||
|
@ -52,7 +52,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
"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.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
|
||||
with_project do
|
||||
output = <<~OUT
|
||||
ERROR: "hanami destroy app" was called with no arguments
|
||||
Usage: "hanami destroy app APP"
|
||||
OUT
|
||||
run_command "hanami destroy app", output, exit_status: 1
|
||||
output = <<-OUT
|
||||
ERROR: "hanami destroy app" was called with no arguments
|
||||
Usage: "hanami destroy app APP"
|
||||
OUT
|
||||
|
||||
run_cmd "hanami destroy app", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
|
||||
it "fails with unknown app" do
|
||||
with_project do
|
||||
output = <<~OUT
|
||||
`unknown' is not a valid APP. Please specify one of: `web'
|
||||
OUT
|
||||
run_command "hanami destroy app unknown", output, exit_status: 1
|
||||
output = <<-OUT
|
||||
`unknown' is not a valid APP. Please specify one of: `web'
|
||||
OUT
|
||||
|
||||
run_cmd "hanami destroy app unknown", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -109,7 +111,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
hanami destroy app admin # Destroy `admin` app
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy app --help", output
|
||||
run_cmd 'hanami destroy app --help', output
|
||||
end
|
||||
end
|
||||
end # app
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
with_project("bookshelf_generate_mailer", test: "rspec") do
|
||||
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("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"
|
||||
OUT
|
||||
|
||||
run_command "hanami generate mailer", output, exit_status: 1
|
||||
run_cmd "hanami generate mailer", output, exit_status: 1
|
||||
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.
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy mailer unknown", output, exit_status: 1
|
||||
run_cmd "hanami destroy mailer unknown", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -67,7 +67,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
hanami destroy mailer welcome # Destroy `WelcomeMailer` mailer
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy mailer --help", output
|
||||
run_cmd 'hanami destroy mailer --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
"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
|
||||
end
|
||||
|
@ -21,20 +21,35 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
|
||||
it "fails with missing argument" do
|
||||
with_project do
|
||||
<<<<<<< HEAD
|
||||
output = <<~OUT
|
||||
ERROR: "hanami destroy migration" was called with no arguments
|
||||
Usage: "hanami destroy migration MIGRATION"
|
||||
OUT
|
||||
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
|
||||
|
||||
it "fails with unknown migration" do
|
||||
with_project do
|
||||
<<<<<<< HEAD
|
||||
output = <<~OUT
|
||||
cannot find `create_unknowns'. Please have a look at `db/migrations' directory to find an existing migration
|
||||
OUT
|
||||
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
|
||||
|
||||
|
@ -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`}
|
||||
]
|
||||
|
||||
<<<<<<< HEAD
|
||||
run_command "hanami destroy migration --help", output
|
||||
=======
|
||||
run_cmd 'hanami destroy migration --help', output
|
||||
>>>>>>> develop
|
||||
end
|
||||
end
|
||||
end # migration
|
||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
"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
|
||||
|
||||
|
@ -43,7 +43,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
"remove lib/bookshelf/entities/user.rb"
|
||||
]
|
||||
|
||||
run_command "hanami destroy model user", output
|
||||
run_cmd "hanami destroy model user", output
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -54,7 +54,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
Usage: "hanami destroy model MODEL"
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy model", output, exit_status: 1
|
||||
run_cmd "hanami destroy model", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -70,7 +70,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
> $ hanami destroy model car
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy model --help", output
|
||||
run_cmd 'hanami destroy model --help', output
|
||||
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.
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy model unknown", output, exit_status: 1
|
||||
run_cmd "hanami destroy model unknown", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -106,7 +106,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
hanami destroy model user # Destroy `User` entity and `UserRepository` repository
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy model --help", output
|
||||
run_cmd 'hanami destroy model --help', output
|
||||
end
|
||||
end
|
||||
end # model
|
||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe "hanami destroy", type: :integration do
|
|||
hanami destroy model MODEL # Destroy a model
|
||||
OUT
|
||||
|
||||
run_command "hanami destroy", output, exit_status: 1
|
||||
run_cmd "hanami destroy", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -66,7 +66,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -114,7 +114,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
|
||||
it "generates non-RESTful actions" 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
|
||||
|
@ -129,7 +129,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
ERROR: "hanami generate action" was called with no arguments
|
||||
Usage: "hanami generate action APP ACTION"
|
||||
OUT
|
||||
run_command "hanami generate action", output, exit_status: 1
|
||||
run_cmd "hanami generate action", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -140,7 +140,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
Usage: "hanami generate action APP ACTION"
|
||||
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
|
||||
|
||||
|
@ -148,7 +148,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
with_project("bookshelf_generate_action_with_unknown_app") do
|
||||
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
|
||||
|
||||
|
@ -159,7 +159,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -171,7 +171,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
it "fails with missing argument" do
|
||||
with_project("bookshelf_generate_action_missing_url") do
|
||||
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
|
||||
|
@ -184,7 +184,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"create spec/web/controllers/status/check_spec.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
|
||||
|
@ -214,7 +214,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"create spec/web/controllers/api/authors/index_spec.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
|
||||
|
@ -247,7 +247,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -259,14 +259,14 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
it "fails with missing argument" 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'"
|
||||
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
|
||||
|
||||
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'"
|
||||
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
|
||||
|
@ -278,7 +278,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -301,7 +301,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -324,7 +324,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -348,7 +348,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -396,7 +396,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -462,7 +462,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
hanami generate action web books#create --skip-view # Skip view and template
|
||||
OUT
|
||||
|
||||
run_command "hanami generate action --help", output
|
||||
run_cmd 'hanami generate action --help', output
|
||||
end
|
||||
end
|
||||
end # action
|
||||
|
|
|
@ -47,7 +47,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
.join("")
|
||||
)
|
||||
|
||||
run_command "hanami generate app #{app}", output
|
||||
run_cmd "hanami generate app #{app}", output
|
||||
|
||||
#
|
||||
# config/environment.rb
|
||||
|
@ -67,7 +67,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -80,7 +80,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
it "fails with missing argument" do
|
||||
with_project("bookshelf_generate_app_missing_application_base_url") do
|
||||
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
|
||||
|
@ -94,7 +94,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -128,7 +128,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -160,7 +160,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -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`
|
||||
OUT
|
||||
|
||||
run_command "hanami generate app --help", output
|
||||
run_cmd 'hanami generate app --help', output
|
||||
end
|
||||
end
|
||||
end # app
|
||||
|
|
|
@ -10,9 +10,9 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"create lib/bookshelf_generate_mailer/mailers/templates/welcome.html.erb"]
|
||||
end
|
||||
|
||||
it "generate the mailer files" do
|
||||
with_project("bookshelf_generate_mailer", test: "rspec") do
|
||||
run_command "hanami generate mailer welcome", output
|
||||
it 'generate the mailer files' do
|
||||
with_project('bookshelf_generate_mailer', test: 'rspec') do
|
||||
run_cmd "hanami generate mailer welcome", output
|
||||
#
|
||||
# lib/bookshelf_generate_mailer/mailers/welcome.rb
|
||||
#
|
||||
|
@ -33,9 +33,9 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
end
|
||||
end
|
||||
|
||||
it "generates a proper minitest file" do
|
||||
with_project("bookshelf_generate_mailer", test: "minitest") do
|
||||
run_command "hanami generate mailer welcome", output
|
||||
it 'generates a proper minitest file' do
|
||||
with_project('bookshelf_generate_mailer', test: 'minitest') do
|
||||
run_cmd "hanami generate mailer welcome", output
|
||||
#
|
||||
# spec/bookshelf_generate_mailer/mailers/welcome_spec.rb
|
||||
#
|
||||
|
@ -51,9 +51,9 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
end
|
||||
end
|
||||
|
||||
it "generates a proper RSpec file" do
|
||||
with_project("bookshelf_generate_mailer", test: "rspec") do
|
||||
run_command "hanami generate mailer welcome", output
|
||||
it 'generates a proper RSpec file' do
|
||||
with_project('bookshelf_generate_mailer', test: 'rspec') do
|
||||
run_cmd "hanami generate mailer welcome", output
|
||||
#
|
||||
# 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"
|
||||
]
|
||||
|
||||
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
|
||||
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"
|
||||
]
|
||||
|
||||
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
|
||||
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"
|
||||
]
|
||||
|
||||
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
|
||||
module Mailers
|
||||
|
@ -150,7 +150,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
Usage: "hanami generate mailer MAILER"
|
||||
OUT
|
||||
|
||||
run_command "hanami generate mailer", output, exit_status: 1
|
||||
run_cmd "hanami generate mailer", output, exit_status: 1
|
||||
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`
|
||||
OUT
|
||||
|
||||
run_command "hanami generate mailer --help", output
|
||||
run_cmd 'hanami generate mailer --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,12 +28,13 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
|
||||
context "with missing argument" do
|
||||
it "fails" do
|
||||
with_project("bookshelf_generate_migration_missing_arguments") do
|
||||
output = <<~END
|
||||
ERROR: "hanami generate migration" was called with no arguments
|
||||
Usage: "hanami generate migration MIGRATION"
|
||||
END
|
||||
run_command "hanami generate migration", output, exit_status: 1
|
||||
with_project('bookshelf_generate_migration_missing_arguments') do
|
||||
output = <<-END
|
||||
ERROR: "hanami generate migration" was called with no arguments
|
||||
Usage: "hanami generate migration MIGRATION"
|
||||
END
|
||||
|
||||
run_cmd "hanami generate migration", output, exit_status: 1
|
||||
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`}
|
||||
]
|
||||
|
||||
run_command "hanami generate migration --help", output
|
||||
run_cmd 'hanami generate migration --help', output
|
||||
end
|
||||
end
|
||||
end # migration
|
||||
|
|
|
@ -30,12 +30,13 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
|
||||
context "with missing argument" do
|
||||
it "fails" do
|
||||
with_project("bookshelf_generate_model_missing_arguments") do
|
||||
output = <<~END
|
||||
ERROR: "hanami generate model" was called with no arguments
|
||||
Usage: "hanami generate model MODEL"
|
||||
END
|
||||
run_command "hanami generate model", output, exit_status: 1
|
||||
with_project('bookshelf_generate_model_missing_arguments') do
|
||||
output = <<-END
|
||||
ERROR: "hanami generate model" was called with no arguments
|
||||
Usage: "hanami generate model MODEL"
|
||||
END
|
||||
|
||||
run_cmd "hanami generate model", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -47,7 +48,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
directory = Pathname.new("db").join("migrations")
|
||||
FileUtils.rm_rf(directory)
|
||||
|
||||
run_command "hanami generate model #{model_name}"
|
||||
run_cmd "hanami generate model #{model_name}"
|
||||
expect(directory).to be_directory
|
||||
|
||||
migration = directory.children.find do |m|
|
||||
|
@ -65,7 +66,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
table_name = "users"
|
||||
project = "bookshelf_generate_model_skip_migration"
|
||||
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
|
||||
#
|
||||
|
@ -83,7 +84,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
table_name = "accounts"
|
||||
project = "bookshelf_generate_model_skip_migration"
|
||||
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
|
||||
#
|
||||
|
@ -111,7 +112,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
/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
|
||||
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/
|
||||
]
|
||||
|
||||
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
|
||||
class SheepRepository < Hanami::Repository
|
||||
|
@ -177,7 +178,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
|
||||
it "returns error for blank option" 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
|
||||
|
@ -194,7 +195,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -233,7 +234,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
"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
|
||||
|
@ -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
|
||||
OUT
|
||||
|
||||
run_command "hanami generate model --help", output
|
||||
run_cmd 'hanami generate model --help', output
|
||||
end
|
||||
end
|
||||
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}`)}
|
||||
]
|
||||
|
||||
run_command "hanami generate secret --help", output
|
||||
run_cmd 'hanami generate secret --help', output
|
||||
end
|
||||
end
|
||||
end # secret
|
||||
|
|
|
@ -13,7 +13,7 @@ RSpec.describe "hanami generate", type: :integration do
|
|||
hanami generate secret [APP] # Generate session secret
|
||||
OUT
|
||||
|
||||
run_command "hanami generate", output, exit_status: 1
|
||||
run_cmd "hanami generate", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
"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
|
||||
#
|
||||
|
@ -63,9 +63,11 @@ RSpec.describe "hanami new", type: :integration do
|
|||
#
|
||||
# .gitignore
|
||||
#
|
||||
expect(".gitignore").to have_file_content <<~END
|
||||
/public/assets*
|
||||
/tmp
|
||||
expect(".gitignore").to have_file_content <<-END
|
||||
/public/assets*
|
||||
/tmp
|
||||
.env.local
|
||||
.env.*.local
|
||||
END
|
||||
end
|
||||
end
|
||||
|
@ -79,7 +81,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
"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
|
||||
#
|
||||
|
@ -132,10 +134,12 @@ RSpec.describe "hanami new", type: :integration do
|
|||
#
|
||||
# .gitignore
|
||||
#
|
||||
expect(".gitignore").to have_file_content <<~END
|
||||
/db/*.sqlite
|
||||
/public/assets*
|
||||
/tmp
|
||||
expect(".gitignore").to have_file_content <<-END
|
||||
/db/*.sqlite
|
||||
/public/assets*
|
||||
/tmp
|
||||
.env.local
|
||||
.env.*.local
|
||||
END
|
||||
end
|
||||
end
|
||||
|
@ -149,7 +153,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
"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
|
||||
#
|
||||
|
@ -202,9 +206,11 @@ RSpec.describe "hanami new", type: :integration do
|
|||
#
|
||||
# .gitignore
|
||||
#
|
||||
expect(".gitignore").to have_file_content <<~END
|
||||
/public/assets*
|
||||
/tmp
|
||||
expect(".gitignore").to have_file_content <<-END
|
||||
/public/assets*
|
||||
/tmp
|
||||
.env.local
|
||||
.env.*.local
|
||||
END
|
||||
end
|
||||
end
|
||||
|
@ -214,7 +220,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
it "returns error" do
|
||||
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 # missing
|
||||
|
||||
|
@ -222,7 +228,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
it "returns error" do
|
||||
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 # unknown
|
||||
end # database
|
||||
|
|
|
@ -5,23 +5,22 @@ RSpec.describe "hanami new", type: :integration do
|
|||
it "generates project" do
|
||||
project = "bookshelf_hanami_head"
|
||||
|
||||
run_command "hanami new #{project} --hanami-head"
|
||||
run_cmd "hanami new #{project} --hanami-head"
|
||||
|
||||
within_project_directory(project) do
|
||||
#
|
||||
# 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-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-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-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-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-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-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-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-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-mailer', require: false, git: 'https://github.com/hanami/mailer.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', git: 'https://github.com/hanami/hanami.git', branch: 'develop'})
|
||||
end
|
||||
end
|
||||
end # hanami-head
|
||||
|
|
|
@ -9,7 +9,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
"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
|
||||
#
|
||||
|
@ -43,7 +43,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
"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
|
||||
#
|
||||
|
@ -74,7 +74,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
"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
|
||||
#
|
||||
|
@ -103,7 +103,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
it "returns error" do
|
||||
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 # missing
|
||||
|
||||
|
@ -111,7 +111,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
it "returns error" do
|
||||
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 # unknown
|
||||
end # template
|
||||
|
|
|
@ -11,7 +11,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
"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
|
||||
#
|
||||
|
@ -79,7 +79,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
"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
|
||||
#
|
||||
|
@ -259,7 +259,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
it "returns error" do
|
||||
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 # missing
|
||||
|
||||
|
@ -267,7 +267,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
it "returns error" do
|
||||
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 # unknown
|
||||
end # test
|
||||
|
|
|
@ -50,11 +50,11 @@ RSpec.describe "hanami new", type: :integration do
|
|||
append .env.test
|
||||
OUT
|
||||
|
||||
run_command "hanami new #{project}", output
|
||||
run_cmd "hanami new #{project}", output
|
||||
|
||||
within_project_directory(project) do
|
||||
# Assert it's an initialized Git repository
|
||||
run_command "git status", "On branch master"
|
||||
run_cmd "git status", "On branch master"
|
||||
|
||||
#
|
||||
# .hanamirc
|
||||
|
@ -117,42 +117,42 @@ RSpec.describe "hanami new", type: :integration do
|
|||
% 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! 🌸
|
||||
END
|
||||
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
|
||||
|
||||
#
|
||||
# Gemfile
|
||||
#
|
||||
if Platform.match?(engine: :ruby)
|
||||
expect("Gemfile").to have_file_content <<~END
|
||||
source 'https://rubygems.org'
|
||||
expect('Gemfile').to have_file_content <<-END
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rake'
|
||||
gem 'hanami', '#{Hanami::Version.gem_requirement}'
|
||||
gem 'hanami-model', '~> 1.3'
|
||||
gem 'rake'
|
||||
gem 'hanami', '#{Hanami::Version.gem_requirement}'
|
||||
gem 'hanami-model', '~> 1.3'
|
||||
|
||||
gem 'sqlite3'
|
||||
gem 'sqlite3'
|
||||
|
||||
group :development do
|
||||
# Code reloading
|
||||
# See: http://hanamirb.org/guides/projects/code-reloading
|
||||
gem 'shotgun', platforms: :ruby
|
||||
gem 'hanami-webconsole'
|
||||
end
|
||||
group :development do
|
||||
# Code reloading
|
||||
# See: https://guides.hanamirb.org/projects/code-reloading
|
||||
gem 'shotgun', platforms: :ruby
|
||||
gem 'hanami-webconsole'
|
||||
end
|
||||
|
||||
group :test, :development do
|
||||
gem 'dotenv', '~> 2.4'
|
||||
end
|
||||
group :test, :development do
|
||||
gem 'dotenv', '~> 2.4'
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'rspec'
|
||||
gem 'capybara'
|
||||
end
|
||||
group :test do
|
||||
gem 'rspec'
|
||||
gem 'capybara'
|
||||
end
|
||||
|
||||
group :production do
|
||||
# gem 'puma'
|
||||
end
|
||||
END
|
||||
group :production do
|
||||
# gem 'puma'
|
||||
end
|
||||
END
|
||||
end
|
||||
|
||||
if Platform.match?(engine: :jruby)
|
||||
|
@ -200,57 +200,57 @@ RSpec.describe "hanami new", type: :integration do
|
|||
#
|
||||
# config/environment.rb
|
||||
#
|
||||
expect("config/environment.rb").to have_file_content <<~END
|
||||
require 'bundler/setup'
|
||||
require 'hanami/setup'
|
||||
require 'hanami/model'
|
||||
require_relative '../lib/#{project}'
|
||||
require_relative '../apps/web/application'
|
||||
expect('config/environment.rb').to have_file_content <<-END
|
||||
require 'bundler/setup'
|
||||
require 'hanami/setup'
|
||||
require 'hanami/model'
|
||||
require_relative '../lib/#{project}'
|
||||
require_relative '../apps/web/application'
|
||||
|
||||
Hanami.configure do
|
||||
mount Web::Application, at: '/'
|
||||
Hanami.configure do
|
||||
mount Web::Application, at: '/'
|
||||
|
||||
model do
|
||||
##
|
||||
# Database adapter
|
||||
#
|
||||
# Available options:
|
||||
#
|
||||
# * SQL adapter
|
||||
# adapter :sql, 'sqlite://db/#{project}_development.sqlite3'
|
||||
# adapter :sql, 'postgresql://localhost/#{project}_development'
|
||||
# adapter :sql, 'mysql://localhost/#{project}_development'
|
||||
#
|
||||
adapter :sql, ENV.fetch('DATABASE_URL')
|
||||
model do
|
||||
##
|
||||
# Database adapter
|
||||
#
|
||||
# Available options:
|
||||
#
|
||||
# * SQL adapter
|
||||
# adapter :sql, 'sqlite://db/#{project}_development.sqlite3'
|
||||
# adapter :sql, 'postgresql://localhost/#{project}_development'
|
||||
# adapter :sql, 'mysql://localhost/#{project}_development'
|
||||
#
|
||||
adapter :sql, ENV.fetch('DATABASE_URL')
|
||||
|
||||
##
|
||||
# Migrations
|
||||
#
|
||||
migrations 'db/migrations'
|
||||
schema 'db/schema.sql'
|
||||
end
|
||||
##
|
||||
# Migrations
|
||||
#
|
||||
migrations 'db/migrations'
|
||||
schema 'db/schema.sql'
|
||||
end
|
||||
|
||||
mailer do
|
||||
root 'lib/#{project}/mailers'
|
||||
mailer do
|
||||
root 'lib/#{project}/mailers'
|
||||
|
||||
# See http://hanamirb.org/guides/mailers/delivery
|
||||
delivery :test
|
||||
end
|
||||
# See https://guides.hanamirb.org/mailers/delivery
|
||||
delivery :test
|
||||
end
|
||||
|
||||
environment :development do
|
||||
# See: http://hanamirb.org/guides/projects/logging
|
||||
logger level: :debug
|
||||
end
|
||||
environment :development do
|
||||
# See: https://guides.hanamirb.org/projects/logging
|
||||
logger level: :debug
|
||||
end
|
||||
|
||||
environment :production do
|
||||
logger level: :info, formatter: :json, filter: []
|
||||
environment :production do
|
||||
logger level: :info, formatter: :json, filter: []
|
||||
|
||||
mailer do
|
||||
delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
|
||||
end
|
||||
end
|
||||
end
|
||||
END
|
||||
mailer do
|
||||
delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
|
||||
end
|
||||
end
|
||||
end
|
||||
END
|
||||
|
||||
project_module = Hanami::Utils::String.new(project).classify
|
||||
#
|
||||
|
@ -451,354 +451,343 @@ RSpec.describe "hanami new", type: :integration do
|
|||
#
|
||||
# .gitignore
|
||||
#
|
||||
expect(".gitignore").to have_file_content <<~END
|
||||
/db/*.sqlite
|
||||
/public/assets*
|
||||
/tmp
|
||||
END
|
||||
expect(".gitignore").to have_file_content <<-END
|
||||
/db/*.sqlite
|
||||
/public/assets*
|
||||
/tmp
|
||||
.env.local
|
||||
.env.*.local
|
||||
END
|
||||
|
||||
#
|
||||
# apps/web/application.rb
|
||||
#
|
||||
expect("apps/web/application.rb").to have_file_content <<~END
|
||||
require 'hanami/helpers'
|
||||
require 'hanami/assets'
|
||||
expect("apps/web/application.rb").to have_file_content <<-END
|
||||
require 'hanami/helpers'
|
||||
require 'hanami/assets'
|
||||
|
||||
module Web
|
||||
class Application < Hanami::Application
|
||||
configure do
|
||||
##
|
||||
# BASIC
|
||||
#
|
||||
module Web
|
||||
class Application < Hanami::Application
|
||||
configure do
|
||||
##
|
||||
# BASIC
|
||||
#
|
||||
|
||||
# Define the root path of this application.
|
||||
# All paths specified in this configuration are relative to path below.
|
||||
#
|
||||
root __dir__
|
||||
# Define the root path of this application.
|
||||
# All paths specified in this configuration are relative to path below.
|
||||
#
|
||||
root __dir__
|
||||
|
||||
# Relative load paths where this application will recursively load the
|
||||
# code.
|
||||
#
|
||||
# When you add new directories, remember to add them here.
|
||||
#
|
||||
load_paths << [
|
||||
'controllers',
|
||||
'views'
|
||||
]
|
||||
# Relative load paths where this application will recursively load the
|
||||
# code.
|
||||
#
|
||||
# When you add new directories, remember to add them here.
|
||||
#
|
||||
load_paths << [
|
||||
'controllers',
|
||||
'views'
|
||||
]
|
||||
|
||||
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
||||
# Defaults to true.
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
||||
#
|
||||
# handle_exceptions true
|
||||
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
||||
# Defaults to true.
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
||||
#
|
||||
# handle_exceptions true
|
||||
|
||||
##
|
||||
# HTTP
|
||||
#
|
||||
##
|
||||
# HTTP
|
||||
#
|
||||
|
||||
# Routes definitions for this application
|
||||
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
||||
#
|
||||
routes 'config/routes'
|
||||
# Routes definitions for this application
|
||||
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
||||
#
|
||||
routes 'config/routes'
|
||||
|
||||
# URI scheme used by the routing system to generate absolute URLs
|
||||
# Defaults to "http"
|
||||
#
|
||||
# scheme 'https'
|
||||
# URI scheme used by the routing system to generate absolute URLs
|
||||
# Defaults to "http"
|
||||
#
|
||||
# scheme 'https'
|
||||
|
||||
# URI host used by the routing system to generate absolute URLs
|
||||
# Defaults to "localhost"
|
||||
#
|
||||
# host 'example.org'
|
||||
# URI host used by the routing system to generate absolute URLs
|
||||
# Defaults to "localhost"
|
||||
#
|
||||
# host 'example.org'
|
||||
|
||||
# URI port used by the routing system to generate absolute URLs
|
||||
# Argument: An object coercible to integer, defaults to 80 if the scheme
|
||||
# is http and 443 if it's https
|
||||
#
|
||||
# This should only be configured if app listens to non-standard ports
|
||||
#
|
||||
# port 443
|
||||
# URI port used by the routing system to generate absolute URLs
|
||||
# Argument: An object coercible to integer, defaults to 80 if the scheme
|
||||
# is http and 443 if it's https
|
||||
#
|
||||
# This should only be configured if app listens to non-standard ports
|
||||
#
|
||||
# port 443
|
||||
|
||||
# Enable cookies
|
||||
# Argument: boolean to toggle the feature
|
||||
# A Hash with options
|
||||
#
|
||||
# Options:
|
||||
# :domain - The domain (String - nil by default, not required)
|
||||
# :path - Restrict cookies to a relative URI
|
||||
# (String - nil by default)
|
||||
# :max_age - Cookies expiration expressed in seconds
|
||||
# (Integer - nil by default)
|
||||
# :secure - Restrict cookies to secure connections
|
||||
# (Boolean - Automatically true when using HTTPS)
|
||||
# See #scheme and #ssl?
|
||||
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
||||
#
|
||||
# cookies true
|
||||
# or
|
||||
# cookies max_age: 300
|
||||
# Enable cookies
|
||||
# Argument: boolean to toggle the feature
|
||||
# A Hash with options
|
||||
#
|
||||
# Options:
|
||||
# :domain - The domain (String - nil by default, not required)
|
||||
# :path - Restrict cookies to a relative URI
|
||||
# (String - nil by default)
|
||||
# :max_age - Cookies expiration expressed in seconds
|
||||
# (Integer - nil by default)
|
||||
# :secure - Restrict cookies to secure connections
|
||||
# (Boolean - Automatically true when using HTTPS)
|
||||
# See #scheme and #ssl?
|
||||
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
||||
#
|
||||
# cookies true
|
||||
# or
|
||||
# cookies max_age: 300
|
||||
|
||||
# Enable sessions
|
||||
# Argument: Symbol the Rack session adapter
|
||||
# A Hash with options
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
||||
#
|
||||
# sessions :cookie, secret: ENV['WEB_SESSIONS_SECRET']
|
||||
# Enable sessions
|
||||
# Argument: Symbol the Rack session adapter
|
||||
# A Hash with options
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
||||
#
|
||||
# sessions :cookie, secret: ENV['WEB_SESSIONS_SECRET']
|
||||
|
||||
# Configure Rack middleware for this application
|
||||
#
|
||||
# middleware.use Rack::Protection
|
||||
# Configure Rack middleware for this application
|
||||
#
|
||||
# middleware.use Rack::Protection
|
||||
|
||||
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
||||
# Argument: A symbol representation of a mime type, defaults to :html
|
||||
#
|
||||
# default_request_format :html
|
||||
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
||||
# Argument: A symbol representation of a mime type, defaults to :html
|
||||
#
|
||||
# default_request_format :html
|
||||
|
||||
# Default format for responses that don't consider the request format
|
||||
# Argument: A symbol representation of a mime type, defaults to :html
|
||||
#
|
||||
# default_response_format :html
|
||||
# Default format for responses that don't consider the request format
|
||||
# Argument: A symbol representation of a mime type, defaults to :html
|
||||
#
|
||||
# default_response_format :html
|
||||
|
||||
# HTTP Body parsers
|
||||
# Parse non GET responses body for a specific mime type
|
||||
# Argument: Symbol, which represent the format of the mime type
|
||||
# (only `:json` is supported)
|
||||
# Object, the parser
|
||||
#
|
||||
# body_parsers :json
|
||||
##
|
||||
# TEMPLATES
|
||||
#
|
||||
|
||||
# When it's true and the router receives a non-encrypted request (http),
|
||||
# it redirects to the secure equivalent (https). Disabled by default.
|
||||
#
|
||||
# force_ssl true
|
||||
# The layout to be used by all views
|
||||
#
|
||||
layout :application # It will load Web::Views::ApplicationLayout
|
||||
|
||||
##
|
||||
# TEMPLATES
|
||||
#
|
||||
# The relative path to templates
|
||||
#
|
||||
templates 'templates'
|
||||
|
||||
# The layout to be used by all views
|
||||
#
|
||||
layout :application # It will load Web::Views::ApplicationLayout
|
||||
##
|
||||
# ASSETS
|
||||
#
|
||||
assets do
|
||||
# JavaScript compressor
|
||||
#
|
||||
# Supported engines:
|
||||
#
|
||||
# * :builtin
|
||||
# * :uglifier
|
||||
# * :yui
|
||||
# * :closure
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/compressors
|
||||
#
|
||||
# In order to skip JavaScript compression comment the following line
|
||||
javascript_compressor :builtin
|
||||
|
||||
# The relative path to templates
|
||||
#
|
||||
templates 'templates'
|
||||
# Stylesheet compressor
|
||||
#
|
||||
# Supported engines:
|
||||
#
|
||||
# * :builtin
|
||||
# * :yui
|
||||
# * :sass
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/compressors
|
||||
#
|
||||
# In order to skip stylesheet compression comment the following line
|
||||
stylesheet_compressor :builtin
|
||||
|
||||
##
|
||||
# ASSETS
|
||||
#
|
||||
assets do
|
||||
# JavaScript compressor
|
||||
#
|
||||
# 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
|
||||
# Specify sources for assets
|
||||
#
|
||||
sources << [
|
||||
'assets'
|
||||
]
|
||||
end
|
||||
|
||||
# Stylesheet compressor
|
||||
#
|
||||
# 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
|
||||
##
|
||||
# SECURITY
|
||||
#
|
||||
|
||||
# Specify sources for assets
|
||||
#
|
||||
sources << [
|
||||
'assets'
|
||||
]
|
||||
end
|
||||
# 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
|
||||
# <iframe> tags by untrusted domains.
|
||||
#
|
||||
# Web applications can send this header to prevent Clickjacking attacks.
|
||||
#
|
||||
# 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'
|
||||
|
||||
##
|
||||
# SECURITY
|
||||
#
|
||||
# X-Content-Type-Options prevents browsers from interpreting files as
|
||||
# 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.
|
||||
# It determines if a web page can or cannot be included via <frame> and
|
||||
# <iframe> tags by untrusted domains.
|
||||
#
|
||||
# Web applications can send this header to prevent Clickjacking attacks.
|
||||
#
|
||||
# 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-XSS-Protection is a HTTP header to determine the behavior of the
|
||||
# browser in case an XSS attack is detected.
|
||||
#
|
||||
# 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'
|
||||
|
||||
# X-Content-Type-Options prevents browsers from interpreting files as
|
||||
# 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'
|
||||
# Content-Security-Policy (CSP) is a HTTP header supported by modern
|
||||
# browsers. It determines trusted sources of execution for dynamic
|
||||
# contents (JavaScript) or other web related assets: stylesheets, images,
|
||||
# fonts, plugins, etc.
|
||||
#
|
||||
# Web applications can send this header to mitigate Cross Site Scripting
|
||||
# (XSS) attacks.
|
||||
#
|
||||
# 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'
|
||||
}
|
||||
|
||||
# X-XSS-Protection is a HTTP header to determine the behavior of the
|
||||
# browser in case an XSS attack is detected.
|
||||
#
|
||||
# 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'
|
||||
##
|
||||
# FRAMEWORKS
|
||||
#
|
||||
|
||||
# Content-Security-Policy (CSP) is a HTTP header supported by modern
|
||||
# browsers. It determines trusted sources of execution for dynamic
|
||||
# contents (JavaScript) or other web related assets: stylesheets, images,
|
||||
# fonts, plugins, etc.
|
||||
#
|
||||
# Web applications can send this header to mitigate Cross Site Scripting
|
||||
# (XSS) attacks.
|
||||
#
|
||||
# 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::Action is included
|
||||
# This is useful for sharing common functionality
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
||||
controller.prepare do
|
||||
# include MyAuthentication # included in all the actions
|
||||
# before :authenticate! # run an authentication before callback
|
||||
end
|
||||
|
||||
##
|
||||
# FRAMEWORKS
|
||||
#
|
||||
# Configure the code that will yield each time Web::View is included
|
||||
# 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
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
||||
controller.prepare do
|
||||
# include MyAuthentication # included in all the actions
|
||||
# before :authenticate! # run an authentication before callback
|
||||
end
|
||||
##
|
||||
# DEVELOPMENT
|
||||
#
|
||||
configure :development do
|
||||
# Don't handle exceptions, render the stack trace
|
||||
handle_exceptions false
|
||||
end
|
||||
|
||||
# Configure the code that will yield each time Web::View is included
|
||||
# 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
|
||||
##
|
||||
# TEST
|
||||
#
|
||||
configure :test do
|
||||
# Don't handle exceptions, render the stack trace
|
||||
handle_exceptions false
|
||||
end
|
||||
|
||||
##
|
||||
# DEVELOPMENT
|
||||
#
|
||||
configure :development do
|
||||
# Don't handle exceptions, render the stack trace
|
||||
handle_exceptions false
|
||||
end
|
||||
##
|
||||
# PRODUCTION
|
||||
#
|
||||
configure :production do
|
||||
# scheme 'https'
|
||||
# host 'example.org'
|
||||
# port 443
|
||||
|
||||
##
|
||||
# TEST
|
||||
#
|
||||
configure :test do
|
||||
# Don't handle exceptions, render the stack trace
|
||||
handle_exceptions false
|
||||
end
|
||||
assets do
|
||||
# Don't compile static assets in production mode (eg. Sass, ES6)
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
||||
compile false
|
||||
|
||||
##
|
||||
# PRODUCTION
|
||||
#
|
||||
configure :production do
|
||||
# scheme 'https'
|
||||
# host 'example.org'
|
||||
# port 443
|
||||
# Use fingerprint file name for asset paths
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/overview
|
||||
fingerprint true
|
||||
|
||||
assets do
|
||||
# Don't compile static assets in production mode (eg. Sass, ES6)
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
||||
compile false
|
||||
# Content Delivery Network (CDN)
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/content-delivery-network
|
||||
#
|
||||
# scheme 'https'
|
||||
# host 'cdn.example.org'
|
||||
# port 443
|
||||
|
||||
# Use fingerprint file name for asset paths
|
||||
#
|
||||
# See: http://hanamirb.org/guides/assets/overview
|
||||
fingerprint true
|
||||
|
||||
# Content Delivery Network (CDN)
|
||||
#
|
||||
# See: http://hanamirb.org/guides/assets/content-delivery-network
|
||||
#
|
||||
# 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
|
||||
# Subresource Integrity
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/content-delivery-network/#subresource-integrity
|
||||
subresource_integrity :sha256
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
END
|
||||
|
||||
#
|
||||
# apps/web/config/routes.rb
|
||||
#
|
||||
expect("apps/web/config/routes.rb").to have_file_content <<~END
|
||||
# Configure your routes here
|
||||
# See: http://hanamirb.org/guides/routing/overview/
|
||||
#
|
||||
# Example:
|
||||
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
|
||||
END
|
||||
expect("apps/web/config/routes.rb").to have_file_content <<-END
|
||||
# Configure your routes here
|
||||
# See: https://guides.hanamirb.org/routing/overview
|
||||
#
|
||||
# Example:
|
||||
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
|
||||
END
|
||||
|
||||
#
|
||||
# apps/web/views/application_layout.rb
|
||||
|
@ -895,7 +884,7 @@ RSpec.describe "hanami new", type: :integration do
|
|||
|
||||
it "generates project" do
|
||||
cd(dir) do
|
||||
run_command "hanami new ."
|
||||
run_cmd "hanami new ."
|
||||
end
|
||||
|
||||
[
|
||||
|
@ -927,41 +916,41 @@ RSpec.describe "hanami new", type: :integration do
|
|||
Usage: "hanami new PROJECT"
|
||||
OUT
|
||||
|
||||
run_command "hanami new", output, exit_status: 1
|
||||
run_cmd "hanami new", output, exit_status: 1
|
||||
end
|
||||
end
|
||||
|
||||
it "prints help message" do
|
||||
output = <<~OUT
|
||||
Command:
|
||||
hanami new
|
||||
it 'prints help message' do
|
||||
output = <<-OUT
|
||||
Command:
|
||||
hanami new
|
||||
|
||||
Usage:
|
||||
hanami new PROJECT
|
||||
Usage:
|
||||
hanami new PROJECT
|
||||
|
||||
Description:
|
||||
Generate a new Hanami project
|
||||
Description:
|
||||
Generate a new Hanami project
|
||||
|
||||
Arguments:
|
||||
PROJECT # REQUIRED The project name
|
||||
Arguments:
|
||||
PROJECT # REQUIRED The project name
|
||||
|
||||
Options:
|
||||
--database=VALUE, -d VALUE # Database (mysql/mysql2/postgresql/postgres/sqlite/sqlite3), default: "sqlite"
|
||||
--application-name=VALUE # App name, default: "web"
|
||||
--application-base-url=VALUE # App base URL, default: "/"
|
||||
--template=VALUE # Template engine (erb/haml/slim), default: "erb"
|
||||
--test=VALUE # Project testing framework (rspec/minitest), default: "rspec"
|
||||
--[no-]hanami-head # Use Hanami HEAD (true/false), default: false
|
||||
--help, -h # Print this help
|
||||
Options:
|
||||
--database=VALUE, -d VALUE # Database (mysql/mysql2/postgresql/postgres/sqlite/sqlite3), default: "sqlite"
|
||||
--application-name=VALUE # App name, default: "web"
|
||||
--application-base-url=VALUE # App base URL, default: "/"
|
||||
--template=VALUE # Template engine (erb/haml/slim), default: "erb"
|
||||
--test=VALUE # Project testing framework (rspec/minitest), default: "rspec"
|
||||
--[no-]hanami-head # Use Hanami HEAD (true/false), default: false
|
||||
--help, -h # Print this help
|
||||
|
||||
Examples:
|
||||
hanami new bookshelf # Basic usage
|
||||
hanami new bookshelf --test=rspec # Setup RSpec testing framework
|
||||
hanami new bookshelf --database=postgres # Setup Postgres database
|
||||
hanami new bookshelf --template=slim # Setup Slim template engine
|
||||
hanami new bookshelf --hanami-head # Use Hanami HEAD
|
||||
OUT
|
||||
Examples:
|
||||
hanami new bookshelf # Basic usage
|
||||
hanami new bookshelf --test=rspec # Setup RSpec testing framework
|
||||
hanami new bookshelf --database=postgres # Setup Postgres database
|
||||
hanami new bookshelf --template=slim # Setup Slim template engine
|
||||
hanami new bookshelf --hanami-head # Use Hanami HEAD
|
||||
OUT
|
||||
|
||||
run_command "hanami new --help", output
|
||||
run_cmd 'hanami new --help', output
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
require "pathname"
|
||||
|
||||
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
|
||||
bundle_exec "hanami"
|
||||
expect(out).to include("hanami plugin [SUBCOMMAND]")
|
||||
end
|
||||
end
|
||||
|
||||
it "executes command from plugin" do
|
||||
xit "executes command from plugin" do
|
||||
with_project do
|
||||
bundle_exec "hanami plugin version"
|
||||
expect(out).to include("v0.1.0")
|
||||
|
@ -22,7 +22,7 @@ RSpec.describe "CLI plugins", type: :integration do
|
|||
project = "bookshelf_without_gemfile"
|
||||
|
||||
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)
|
||||
|
||||
expect(destination).to exist
|
||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe "hanami routes", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami routes --help", output
|
||||
run_cmd 'hanami routes --help', output
|
||||
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("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
|
||||
|
@ -25,7 +25,7 @@ RSpec.describe "hanami server", type: :integration do
|
|||
server do
|
||||
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
|
||||
|
@ -114,7 +114,7 @@ RSpec.describe "hanami server", type: :integration do
|
|||
touch 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
|
||||
visit "/?ping=pong"
|
||||
|
@ -132,7 +132,7 @@ RSpec.describe "hanami server", type: :integration do
|
|||
touch 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
|
||||
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}")
|
||||
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"})'
|
||||
|
||||
server do
|
||||
|
@ -529,36 +529,36 @@ RSpec.describe "hanami server", type: :integration do
|
|||
|
||||
it "prints help message" do
|
||||
with_project do
|
||||
output = <<~OUT
|
||||
Command:
|
||||
hanami server
|
||||
output = <<-OUT
|
||||
Command:
|
||||
hanami server
|
||||
|
||||
Usage:
|
||||
hanami server
|
||||
Usage:
|
||||
hanami server
|
||||
|
||||
Description:
|
||||
Start Hanami server (only for development)
|
||||
Description:
|
||||
Start Hanami server (only for development)
|
||||
|
||||
Options:
|
||||
--server=VALUE # Force a server engine (eg, webrick, puma, thin, etc..)
|
||||
--host=VALUE # The host address to bind to
|
||||
--port=VALUE, -p VALUE # The port to run the server on
|
||||
--debug=VALUE # Turn on debug output
|
||||
--warn=VALUE # Turn on warnings
|
||||
--daemonize=VALUE # Daemonize the server
|
||||
--pid=VALUE # Path to write a pid file after daemonize
|
||||
--[no-]code-reloading # Code reloading, default: true
|
||||
--help, -h # Print this help
|
||||
Options:
|
||||
--server=VALUE # Force a server engine (eg, webrick, puma, thin, etc..)
|
||||
--host=VALUE # The host address to bind to
|
||||
--port=VALUE, -p VALUE # The port to run the server on
|
||||
--debug=VALUE # Turn on debug output
|
||||
--warn=VALUE # Turn on warnings
|
||||
--daemonize=VALUE # Daemonize the server
|
||||
--pid=VALUE # Path to write a pid file after daemonize
|
||||
--[no-]code-reloading # Code reloading, default: true
|
||||
--help, -h # Print this help
|
||||
|
||||
Examples:
|
||||
hanami server # Basic usage (it uses the bundled server engine)
|
||||
hanami server --server=webrick # Force `webrick` server engine
|
||||
hanami server --host=0.0.0.0 # Bind to a host
|
||||
hanami server --port=2306 # Bind to a port
|
||||
hanami server --no-code-reloading # Disable code reloading
|
||||
OUT
|
||||
Examples:
|
||||
hanami server # Basic usage (it uses the bundled server engine)
|
||||
hanami server --server=webrick # Force `webrick` server engine
|
||||
hanami server --host=0.0.0.0 # Bind to a host
|
||||
hanami server --port=2306 # Bind to a port
|
||||
hanami server --no-code-reloading # Disable code reloading
|
||||
OUT
|
||||
|
||||
run_command "hanami server --help", output
|
||||
run_cmd 'hanami server --help', output
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,25 +4,25 @@ RSpec.describe "hanami version", type: :integration do
|
|||
context "within a project" do
|
||||
it "prints current version" do
|
||||
with_project 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
|
||||
with_project 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
|
||||
with_project 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
|
||||
with_project do
|
||||
run_command "hanami --version", "v#{Hanami::VERSION}"
|
||||
run_cmd 'hanami --version', "v#{Hanami::VERSION}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,26 +42,26 @@ RSpec.describe "hanami version", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami version --help", output
|
||||
run_cmd 'hanami version --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "outside of a project" do
|
||||
it "prints current version" do
|
||||
run_command "hanami version", "v#{Hanami::VERSION}"
|
||||
it 'prints current version' do
|
||||
run_cmd 'hanami version', "v#{Hanami::VERSION}"
|
||||
end
|
||||
|
||||
it "prints current version with v alias" do
|
||||
run_command "hanami v", "v#{Hanami::VERSION}"
|
||||
it 'prints current version with v alias' do
|
||||
run_cmd 'hanami v', "v#{Hanami::VERSION}"
|
||||
end
|
||||
|
||||
it "prints current version with -v alias" do
|
||||
run_command "hanami -v", "v#{Hanami::VERSION}"
|
||||
it 'prints current version with -v alias' do
|
||||
run_cmd 'hanami -v', "v#{Hanami::VERSION}"
|
||||
end
|
||||
|
||||
it "prints current version with --version alias" do
|
||||
run_command "hanami --version", "v#{Hanami::VERSION}"
|
||||
it 'prints current version with --version alias' do
|
||||
run_cmd 'hanami --version', "v#{Hanami::VERSION}"
|
||||
end
|
||||
|
||||
it "prints help message" do
|
||||
|
@ -79,7 +79,7 @@ RSpec.describe "hanami version", type: :integration do
|
|||
--help, -h # Print this help
|
||||
OUT
|
||||
|
||||
run_command "hanami version --help", output
|
||||
run_cmd 'hanami version --help', output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -104,7 +104,7 @@ RSpec.describe "handle exceptions", type: :integration do
|
|||
|
||||
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 include("<h1>Boot Error</h1><p>Something went wrong while loading")
|
||||
expect(last_response.body).to include("Error from custom template")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -209,7 +209,7 @@ RSpec.describe "handle exceptions", type: :integration do
|
|||
|
||||
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 include("<h1>Boot Error</h1><p>Something went wrong while loading")
|
||||
expect(last_response.body).to include("Error from custom template")
|
||||
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
|
||||
context "with Minitest" do
|
||||
it "runs tests" do
|
||||
xit "runs tests" do
|
||||
with_project("bookshelf", test: "minitest") do
|
||||
setup_model
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe "force SSL", type: :integration do
|
|||
with_project(project, server: :puma) do
|
||||
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["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("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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
HANAMI_PORT=42
|
||||
BAZ="yes"
|
||||
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
|
||||
OUT
|
||||
|
||||
run_command "hanami generate app #{input}", output
|
||||
run_cmd "hanami generate app #{input}", output
|
||||
|
||||
#
|
||||
# apps/<app>/application.rb
|
||||
#
|
||||
expect("apps/#{app}/application.rb").to have_file_content <<~END
|
||||
require 'hanami/helpers'
|
||||
require 'hanami/assets'
|
||||
expect("apps/#{app}/application.rb").to have_file_content <<-END
|
||||
require 'hanami/helpers'
|
||||
require 'hanami/assets'
|
||||
|
||||
module #{app_name}
|
||||
class Application < Hanami::Application
|
||||
configure do
|
||||
##
|
||||
# BASIC
|
||||
#
|
||||
module #{app_name}
|
||||
class Application < Hanami::Application
|
||||
configure do
|
||||
##
|
||||
# BASIC
|
||||
#
|
||||
|
||||
# Define the root path of this application.
|
||||
# All paths specified in this configuration are relative to path below.
|
||||
#
|
||||
root __dir__
|
||||
# Define the root path of this application.
|
||||
# All paths specified in this configuration are relative to path below.
|
||||
#
|
||||
root __dir__
|
||||
|
||||
# Relative load paths where this application will recursively load the
|
||||
# code.
|
||||
#
|
||||
# When you add new directories, remember to add them here.
|
||||
#
|
||||
load_paths << [
|
||||
'controllers',
|
||||
'views'
|
||||
]
|
||||
# Relative load paths where this application will recursively load the
|
||||
# code.
|
||||
#
|
||||
# When you add new directories, remember to add them here.
|
||||
#
|
||||
load_paths << [
|
||||
'controllers',
|
||||
'views'
|
||||
]
|
||||
|
||||
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
||||
# Defaults to true.
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
||||
#
|
||||
# handle_exceptions true
|
||||
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
||||
# Defaults to true.
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller/#Exceptions_management
|
||||
#
|
||||
# handle_exceptions true
|
||||
|
||||
##
|
||||
# HTTP
|
||||
#
|
||||
##
|
||||
# HTTP
|
||||
#
|
||||
|
||||
# Routes definitions for this application
|
||||
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
||||
#
|
||||
routes 'config/routes'
|
||||
# Routes definitions for this application
|
||||
# See: http://www.rubydoc.info/gems/hanami-router#Usage
|
||||
#
|
||||
routes 'config/routes'
|
||||
|
||||
# URI scheme used by the routing system to generate absolute URLs
|
||||
# Defaults to "http"
|
||||
#
|
||||
# scheme 'https'
|
||||
# URI scheme used by the routing system to generate absolute URLs
|
||||
# Defaults to "http"
|
||||
#
|
||||
# scheme 'https'
|
||||
|
||||
# URI host used by the routing system to generate absolute URLs
|
||||
# Defaults to "localhost"
|
||||
#
|
||||
# host 'example.org'
|
||||
# URI host used by the routing system to generate absolute URLs
|
||||
# Defaults to "localhost"
|
||||
#
|
||||
# host 'example.org'
|
||||
|
||||
# URI port used by the routing system to generate absolute URLs
|
||||
# Argument: An object coercible to integer, defaults to 80 if the scheme
|
||||
# is http and 443 if it's https
|
||||
#
|
||||
# This should only be configured if app listens to non-standard ports
|
||||
#
|
||||
# port 443
|
||||
# URI port used by the routing system to generate absolute URLs
|
||||
# Argument: An object coercible to integer, defaults to 80 if the scheme
|
||||
# is http and 443 if it's https
|
||||
#
|
||||
# This should only be configured if app listens to non-standard ports
|
||||
#
|
||||
# port 443
|
||||
|
||||
# Enable cookies
|
||||
# Argument: boolean to toggle the feature
|
||||
# A Hash with options
|
||||
#
|
||||
# Options:
|
||||
# :domain - The domain (String - nil by default, not required)
|
||||
# :path - Restrict cookies to a relative URI
|
||||
# (String - nil by default)
|
||||
# :max_age - Cookies expiration expressed in seconds
|
||||
# (Integer - nil by default)
|
||||
# :secure - Restrict cookies to secure connections
|
||||
# (Boolean - Automatically true when using HTTPS)
|
||||
# See #scheme and #ssl?
|
||||
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
||||
#
|
||||
# cookies true
|
||||
# or
|
||||
# cookies max_age: 300
|
||||
# Enable cookies
|
||||
# Argument: boolean to toggle the feature
|
||||
# A Hash with options
|
||||
#
|
||||
# Options:
|
||||
# :domain - The domain (String - nil by default, not required)
|
||||
# :path - Restrict cookies to a relative URI
|
||||
# (String - nil by default)
|
||||
# :max_age - Cookies expiration expressed in seconds
|
||||
# (Integer - nil by default)
|
||||
# :secure - Restrict cookies to secure connections
|
||||
# (Boolean - Automatically true when using HTTPS)
|
||||
# See #scheme and #ssl?
|
||||
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
||||
#
|
||||
# cookies true
|
||||
# or
|
||||
# cookies max_age: 300
|
||||
|
||||
# Enable sessions
|
||||
# Argument: Symbol the Rack session adapter
|
||||
# A Hash with options
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
||||
#
|
||||
# sessions :cookie, secret: ENV['#{app_upcase}_SESSIONS_SECRET']
|
||||
# Enable sessions
|
||||
# Argument: Symbol the Rack session adapter
|
||||
# A Hash with options
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
||||
#
|
||||
# sessions :cookie, secret: ENV['#{app_upcase}_SESSIONS_SECRET']
|
||||
|
||||
# Configure Rack middleware for this application
|
||||
#
|
||||
# middleware.use Rack::Protection
|
||||
# Configure Rack middleware for this application
|
||||
#
|
||||
# middleware.use Rack::Protection
|
||||
|
||||
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
||||
# Argument: A symbol representation of a mime type, defaults to :html
|
||||
#
|
||||
# default_request_format :html
|
||||
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
||||
# Argument: A symbol representation of a mime type, defaults to :html
|
||||
#
|
||||
# default_request_format :html
|
||||
|
||||
# Default format for responses that don't consider the request format
|
||||
# Argument: A symbol representation of a mime type, defaults to :html
|
||||
#
|
||||
# default_response_format :html
|
||||
# Default format for responses that don't consider the request format
|
||||
# Argument: A symbol representation of a mime type, defaults to :html
|
||||
#
|
||||
# default_response_format :html
|
||||
|
||||
# HTTP Body parsers
|
||||
# Parse non GET responses body for a specific mime type
|
||||
# Argument: Symbol, which represent the format of the mime type
|
||||
# (only `:json` is supported)
|
||||
# Object, the parser
|
||||
#
|
||||
# body_parsers :json
|
||||
##
|
||||
# TEMPLATES
|
||||
#
|
||||
|
||||
# When it's true and the router receives a non-encrypted request (http),
|
||||
# it redirects to the secure equivalent (https). Disabled by default.
|
||||
#
|
||||
# force_ssl true
|
||||
# The layout to be used by all views
|
||||
#
|
||||
layout :application # It will load #{app_name}::Views::ApplicationLayout
|
||||
|
||||
##
|
||||
# TEMPLATES
|
||||
#
|
||||
# The relative path to templates
|
||||
#
|
||||
templates 'templates'
|
||||
|
||||
# The layout to be used by all views
|
||||
#
|
||||
layout :application # It will load #{app_name}::Views::ApplicationLayout
|
||||
##
|
||||
# ASSETS
|
||||
#
|
||||
assets do
|
||||
# JavaScript compressor
|
||||
#
|
||||
# Supported engines:
|
||||
#
|
||||
# * :builtin
|
||||
# * :uglifier
|
||||
# * :yui
|
||||
# * :closure
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/compressors
|
||||
#
|
||||
# In order to skip JavaScript compression comment the following line
|
||||
javascript_compressor :builtin
|
||||
|
||||
# The relative path to templates
|
||||
#
|
||||
templates 'templates'
|
||||
# Stylesheet compressor
|
||||
#
|
||||
# Supported engines:
|
||||
#
|
||||
# * :builtin
|
||||
# * :yui
|
||||
# * :sass
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/compressors
|
||||
#
|
||||
# In order to skip stylesheet compression comment the following line
|
||||
stylesheet_compressor :builtin
|
||||
|
||||
##
|
||||
# ASSETS
|
||||
#
|
||||
assets do
|
||||
# JavaScript compressor
|
||||
#
|
||||
# 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
|
||||
# Specify sources for assets
|
||||
#
|
||||
sources << [
|
||||
'assets'
|
||||
]
|
||||
end
|
||||
|
||||
# Stylesheet compressor
|
||||
#
|
||||
# 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
|
||||
##
|
||||
# SECURITY
|
||||
#
|
||||
|
||||
# Specify sources for assets
|
||||
#
|
||||
sources << [
|
||||
'assets'
|
||||
]
|
||||
end
|
||||
# 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
|
||||
# <iframe> tags by untrusted domains.
|
||||
#
|
||||
# Web applications can send this header to prevent Clickjacking attacks.
|
||||
#
|
||||
# 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'
|
||||
|
||||
##
|
||||
# SECURITY
|
||||
#
|
||||
# X-Content-Type-Options prevents browsers from interpreting files as
|
||||
# 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.
|
||||
# It determines if a web page can or cannot be included via <frame> and
|
||||
# <iframe> tags by untrusted domains.
|
||||
#
|
||||
# Web applications can send this header to prevent Clickjacking attacks.
|
||||
#
|
||||
# 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-XSS-Protection is a HTTP header to determine the behavior of the
|
||||
# browser in case an XSS attack is detected.
|
||||
#
|
||||
# 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'
|
||||
|
||||
# X-Content-Type-Options prevents browsers from interpreting files as
|
||||
# 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'
|
||||
# Content-Security-Policy (CSP) is a HTTP header supported by modern
|
||||
# browsers. It determines trusted sources of execution for dynamic
|
||||
# contents (JavaScript) or other web related assets: stylesheets, images,
|
||||
# fonts, plugins, etc.
|
||||
#
|
||||
# Web applications can send this header to mitigate Cross Site Scripting
|
||||
# (XSS) attacks.
|
||||
#
|
||||
# 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'
|
||||
}
|
||||
|
||||
# X-XSS-Protection is a HTTP header to determine the behavior of the
|
||||
# browser in case an XSS attack is detected.
|
||||
#
|
||||
# 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'
|
||||
##
|
||||
# FRAMEWORKS
|
||||
#
|
||||
|
||||
# Content-Security-Policy (CSP) is a HTTP header supported by modern
|
||||
# browsers. It determines trusted sources of execution for dynamic
|
||||
# contents (JavaScript) or other web related assets: stylesheets, images,
|
||||
# fonts, plugins, etc.
|
||||
#
|
||||
# Web applications can send this header to mitigate Cross Site Scripting
|
||||
# (XSS) attacks.
|
||||
#
|
||||
# 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}::Action is included
|
||||
# This is useful for sharing common functionality
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
||||
controller.prepare do
|
||||
# include MyAuthentication # included in all the actions
|
||||
# before :authenticate! # run an authentication before callback
|
||||
end
|
||||
|
||||
##
|
||||
# FRAMEWORKS
|
||||
#
|
||||
# Configure the code that will yield each time #{app_name}::View is included
|
||||
# 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
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/hanami-controller#Configuration
|
||||
controller.prepare do
|
||||
# include MyAuthentication # included in all the actions
|
||||
# before :authenticate! # run an authentication before callback
|
||||
end
|
||||
##
|
||||
# DEVELOPMENT
|
||||
#
|
||||
configure :development do
|
||||
# Don't handle exceptions, render the stack trace
|
||||
handle_exceptions false
|
||||
end
|
||||
|
||||
# Configure the code that will yield each time #{app_name}::View is included
|
||||
# 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
|
||||
##
|
||||
# TEST
|
||||
#
|
||||
configure :test do
|
||||
# Don't handle exceptions, render the stack trace
|
||||
handle_exceptions false
|
||||
end
|
||||
|
||||
##
|
||||
# DEVELOPMENT
|
||||
#
|
||||
configure :development do
|
||||
# Don't handle exceptions, render the stack trace
|
||||
handle_exceptions false
|
||||
end
|
||||
##
|
||||
# PRODUCTION
|
||||
#
|
||||
configure :production do
|
||||
# scheme 'https'
|
||||
# host 'example.org'
|
||||
# port 443
|
||||
|
||||
##
|
||||
# TEST
|
||||
#
|
||||
configure :test do
|
||||
# Don't handle exceptions, render the stack trace
|
||||
handle_exceptions false
|
||||
end
|
||||
assets do
|
||||
# Don't compile static assets in production mode (eg. Sass, ES6)
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
||||
compile false
|
||||
|
||||
##
|
||||
# PRODUCTION
|
||||
#
|
||||
configure :production do
|
||||
# scheme 'https'
|
||||
# host 'example.org'
|
||||
# port 443
|
||||
# Use fingerprint file name for asset paths
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/overview
|
||||
fingerprint true
|
||||
|
||||
assets do
|
||||
# Don't compile static assets in production mode (eg. Sass, ES6)
|
||||
#
|
||||
# See: http://www.rubydoc.info/gems/hanami-assets#Configuration
|
||||
compile false
|
||||
# Content Delivery Network (CDN)
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/content-delivery-network
|
||||
#
|
||||
# scheme 'https'
|
||||
# host 'cdn.example.org'
|
||||
# port 443
|
||||
|
||||
# Use fingerprint file name for asset paths
|
||||
#
|
||||
# See: http://hanamirb.org/guides/assets/overview
|
||||
fingerprint true
|
||||
|
||||
# Content Delivery Network (CDN)
|
||||
#
|
||||
# See: http://hanamirb.org/guides/assets/content-delivery-network
|
||||
#
|
||||
# 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
|
||||
# Subresource Integrity
|
||||
#
|
||||
# See: https://guides.hanamirb.org/assets/content-delivery-network/#subresource-integrity
|
||||
subresource_integrity :sha256
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
END
|
||||
|
||||
#
|
||||
# apps/<app>/config/routes.rb
|
||||
#
|
||||
expect("apps/#{app}/config/routes.rb").to have_file_content <<~END
|
||||
# Configure your routes here
|
||||
# See: http://hanamirb.org/guides/routing/overview/
|
||||
#
|
||||
# Example:
|
||||
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
|
||||
END
|
||||
expect("apps/#{app}/config/routes.rb").to have_file_content <<-END
|
||||
# Configure your routes here
|
||||
# See: https://guides.hanamirb.org/routing/overview
|
||||
#
|
||||
# Example:
|
||||
# get '/hello', to: ->(env) { [200, {}, ['Hello from Hanami!']] }
|
||||
END
|
||||
|
||||
#
|
||||
# apps/<app>/views/application_layout.rb
|
||||
|
@ -431,59 +418,59 @@ RSpec.shared_examples "a new app" do
|
|||
#
|
||||
# config/environment.rb
|
||||
#
|
||||
expect("config/environment.rb").to have_file_content <<~END
|
||||
require 'bundler/setup'
|
||||
require 'hanami/setup'
|
||||
require 'hanami/model'
|
||||
require_relative '../lib/#{project}'
|
||||
require_relative '../apps/web/application'
|
||||
require_relative '../apps/#{app}/application'
|
||||
expect("config/environment.rb").to have_file_content <<-END
|
||||
require 'bundler/setup'
|
||||
require 'hanami/setup'
|
||||
require 'hanami/model'
|
||||
require_relative '../lib/#{project}'
|
||||
require_relative '../apps/web/application'
|
||||
require_relative '../apps/#{app}/application'
|
||||
|
||||
Hanami.configure do
|
||||
mount #{app_name}::Application, at: '/#{app}'
|
||||
mount Web::Application, at: '/'
|
||||
Hanami.configure do
|
||||
mount #{app_name}::Application, at: '/#{app}'
|
||||
mount Web::Application, at: '/'
|
||||
|
||||
model do
|
||||
##
|
||||
# Database adapter
|
||||
#
|
||||
# Available options:
|
||||
#
|
||||
# * SQL adapter
|
||||
# adapter :sql, 'sqlite://db/#{project}_development.sqlite3'
|
||||
# adapter :sql, 'postgresql://localhost/#{project}_development'
|
||||
# adapter :sql, 'mysql://localhost/#{project}_development'
|
||||
#
|
||||
adapter :sql, ENV.fetch('DATABASE_URL')
|
||||
model do
|
||||
##
|
||||
# Database adapter
|
||||
#
|
||||
# Available options:
|
||||
#
|
||||
# * SQL adapter
|
||||
# adapter :sql, 'sqlite://db/#{project}_development.sqlite3'
|
||||
# adapter :sql, 'postgresql://localhost/#{project}_development'
|
||||
# adapter :sql, 'mysql://localhost/#{project}_development'
|
||||
#
|
||||
adapter :sql, ENV.fetch('DATABASE_URL')
|
||||
|
||||
##
|
||||
# Migrations
|
||||
#
|
||||
migrations 'db/migrations'
|
||||
schema 'db/schema.sql'
|
||||
end
|
||||
##
|
||||
# Migrations
|
||||
#
|
||||
migrations 'db/migrations'
|
||||
schema 'db/schema.sql'
|
||||
end
|
||||
|
||||
mailer do
|
||||
root 'lib/#{project}/mailers'
|
||||
mailer do
|
||||
root 'lib/#{project}/mailers'
|
||||
|
||||
# See http://hanamirb.org/guides/mailers/delivery
|
||||
delivery :test
|
||||
end
|
||||
# See https://guides.hanamirb.org/mailers/delivery
|
||||
delivery :test
|
||||
end
|
||||
|
||||
environment :development do
|
||||
# See: http://hanamirb.org/guides/projects/logging
|
||||
logger level: :debug
|
||||
end
|
||||
environment :development do
|
||||
# See: https://guides.hanamirb.org/projects/logging
|
||||
logger level: :debug
|
||||
end
|
||||
|
||||
environment :production do
|
||||
logger level: :info, formatter: :json, filter: []
|
||||
environment :production do
|
||||
logger level: :info, formatter: :json, filter: []
|
||||
|
||||
mailer do
|
||||
delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
|
||||
end
|
||||
end
|
||||
end
|
||||
END
|
||||
mailer do
|
||||
delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT')
|
||||
end
|
||||
end
|
||||
end
|
||||
END
|
||||
|
||||
#
|
||||
# .env.development
|
||||
|
|
|
@ -9,7 +9,7 @@ RSpec.shared_examples "a new migration" do
|
|||
project = "bookshelf_generate_migration_#{Random.rand(100_000_000)}"
|
||||
|
||||
with_project(project) do
|
||||
run_command "hanami generate migration #{input}", migration
|
||||
run_cmd "hanami generate migration #{input}", migration
|
||||
|
||||
#
|
||||
# db/migrations/<timestamp>_<migration>.rb
|
||||
|
|
|
@ -19,7 +19,7 @@ RSpec.shared_examples "a new model" do
|
|||
"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
|
||||
|
|
|
@ -5,8 +5,8 @@ require "hanami/utils/string"
|
|||
RSpec.shared_examples "a new project" do
|
||||
let(:project) { Hanami::Utils::String.new(input).underscore.to_s }
|
||||
|
||||
it "generates vanilla project" do
|
||||
run_command "hanami new #{input}"
|
||||
it 'generates vanilla project' do
|
||||
run_cmd "hanami new #{input}"
|
||||
|
||||
[
|
||||
"create lib/#{project}.rb",
|
||||
|
@ -85,11 +85,13 @@ RSpec.shared_examples "a new project" do
|
|||
#
|
||||
# .gitignore
|
||||
#
|
||||
expect(".gitignore").to have_file_content <<~END
|
||||
/db/*.sqlite
|
||||
/public/assets*
|
||||
/tmp
|
||||
END
|
||||
expect(".gitignore").to have_file_content <<-END
|
||||
/db/*.sqlite
|
||||
/public/assets*
|
||||
/tmp
|
||||
.env.local
|
||||
.env.*.local
|
||||
END
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue