hanami 2.0.0.beta2 → 2.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/lib/hanami/configuration/null_configuration.rb +2 -2
- data/lib/hanami/configuration.rb +17 -17
- data/lib/hanami/routes.rb +48 -21
- data/lib/hanami/version.rb +1 -1
- data/spec/{new_integration → integration}/action/cookies_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/csrf_protection_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/routes_spec.rb +3 -5
- data/spec/{new_integration → integration}/action/sessions_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/slice_configuration_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/view_integration_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/view_rendering/automatic_rendering_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/view_rendering/paired_view_inference_spec.rb +0 -0
- data/spec/{new_integration → integration}/action/view_rendering_spec.rb +0 -0
- data/spec/{new_integration → integration}/code_loading/loading_from_app_spec.rb +0 -0
- data/spec/{new_integration → integration}/code_loading/loading_from_lib_spec.rb +0 -0
- data/spec/{new_integration → integration}/code_loading/loading_from_slice_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/application_routes_helper_spec.rb +1 -3
- data/spec/{new_integration → integration}/container/auto_injection_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/auto_registration_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/autoloader_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/imports_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/prepare_container_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/shutdown_spec.rb +0 -0
- data/spec/{new_integration → integration}/container/standard_bootable_components_spec.rb +0 -0
- data/spec/{new_integration → integration}/dotenv_loading_spec.rb +0 -0
- data/spec/{new_integration → integration}/rack_app/middleware_spec.rb +9 -15
- data/spec/{new_integration → integration}/rack_app/non_booted_rack_app_spec.rb +3 -5
- data/spec/{new_integration → integration}/rack_app/rack_app_spec.rb +28 -48
- data/spec/{new_integration → integration}/settings/access_to_constants_spec.rb +0 -0
- data/spec/{new_integration → integration}/settings/loading_from_env_spec.rb +0 -0
- data/spec/{new_integration → integration}/settings/settings_component_loading_spec.rb +0 -0
- data/spec/{new_integration → integration}/settings/using_types_spec.rb +0 -0
- data/spec/{new_integration → integration}/setup_spec.rb +20 -0
- data/spec/{new_integration → integration}/slices/external_slice_spec.rb +2 -4
- data/spec/{new_integration → integration}/slices/slice_configuration_spec.rb +0 -0
- data/spec/{new_integration → integration}/slices/slice_loading_spec.rb +0 -0
- data/spec/{new_integration → integration}/slices/slice_routing_spec.rb +5 -13
- data/spec/{new_integration → integration}/slices/slice_settings_spec.rb +0 -0
- data/spec/{new_integration → integration}/slices_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/context/assets_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/context/inflector_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/context/request_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/context/routes_spec.rb +1 -3
- data/spec/{new_integration → integration}/view/context/settings_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/inflector_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/part_namespace_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/path_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/slice_configuration_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/template_spec.rb +0 -0
- data/spec/{new_integration → integration}/view/views_spec.rb +0 -0
- data/spec/unit/hanami/configuration/actions_spec.rb +4 -15
- data/spec/unit/hanami/configuration/router_spec.rb +45 -0
- data/spec/unit/hanami/configuration/views_spec.rb +4 -15
- data/spec/unit/hanami/version_spec.rb +1 -1
- metadata +97 -244
- data/lib/hanami/server.rb +0 -29
- data/spec/integration/application_middleware_stack_spec.rb +0 -84
- data/spec/integration/assets/cdn_spec.rb +0 -48
- data/spec/integration/assets/fingerprint_spec.rb +0 -42
- data/spec/integration/assets/helpers_spec.rb +0 -50
- data/spec/integration/assets/serve_spec.rb +0 -70
- data/spec/integration/assets/subresource_integrity_spec.rb +0 -54
- data/spec/integration/body_parsers_spec.rb +0 -50
- data/spec/integration/cli/assets/precompile_spec.rb +0 -147
- data/spec/integration/cli/assets_spec.rb +0 -14
- data/spec/integration/cli/console_spec.rb +0 -105
- data/spec/integration/cli/db/apply_spec.rb +0 -74
- data/spec/integration/cli/db/console_spec.rb +0 -40
- data/spec/integration/cli/db/create_spec.rb +0 -50
- data/spec/integration/cli/db/drop_spec.rb +0 -54
- data/spec/integration/cli/db/migrate_spec.rb +0 -108
- data/spec/integration/cli/db/prepare_spec.rb +0 -36
- data/spec/integration/cli/db/rollback_spec.rb +0 -96
- data/spec/integration/cli/db/version_spec.rb +0 -38
- data/spec/integration/cli/db_spec.rb +0 -21
- data/spec/integration/cli/destroy/action_spec.rb +0 -143
- data/spec/integration/cli/destroy/app_spec.rb +0 -118
- data/spec/integration/cli/destroy/mailer_spec.rb +0 -74
- data/spec/integration/cli/destroy/migration_spec.rb +0 -70
- data/spec/integration/cli/destroy/model_spec.rb +0 -113
- data/spec/integration/cli/destroy_spec.rb +0 -18
- data/spec/integration/cli/generate/action_spec.rb +0 -469
- data/spec/integration/cli/generate/app_spec.rb +0 -215
- data/spec/integration/cli/generate/mailer_spec.rb +0 -189
- data/spec/integration/cli/generate/migration_spec.rb +0 -72
- data/spec/integration/cli/generate/model_spec.rb +0 -290
- data/spec/integration/cli/generate/secret_spec.rb +0 -56
- data/spec/integration/cli/generate_spec.rb +0 -19
- data/spec/integration/cli/new/database_spec.rb +0 -235
- data/spec/integration/cli/new/hanami_head_spec.rb +0 -27
- data/spec/integration/cli/new/template_spec.rb +0 -118
- data/spec/integration/cli/new/test_spec.rb +0 -274
- data/spec/integration/cli/new_spec.rb +0 -970
- data/spec/integration/cli/plugins_spec.rb +0 -39
- data/spec/integration/cli/routes_spec.rb +0 -49
- data/spec/integration/cli/server_spec.rb +0 -626
- data/spec/integration/cli/version_spec.rb +0 -85
- data/spec/integration/early_hints_spec.rb +0 -35
- data/spec/integration/handle_exceptions_spec.rb +0 -244
- data/spec/integration/head_spec.rb +0 -89
- data/spec/integration/http_headers_spec.rb +0 -29
- data/spec/integration/mailer_spec.rb +0 -32
- data/spec/integration/middleware_spec.rb +0 -81
- data/spec/integration/mount_applications_spec.rb +0 -88
- data/spec/integration/project_initializers_spec.rb +0 -40
- data/spec/integration/rackup_spec.rb +0 -35
- data/spec/integration/rake/with_minitest_spec.rb +0 -67
- data/spec/integration/rake/with_rspec_spec.rb +0 -69
- data/spec/integration/routing_helpers_spec.rb +0 -61
- data/spec/integration/security/content_security_policy_spec.rb +0 -46
- data/spec/integration/security/csrf_protection_spec.rb +0 -42
- data/spec/integration/security/force_ssl_spec.rb +0 -29
- data/spec/integration/security/x_content_type_options_spec.rb +0 -46
- data/spec/integration/security/x_frame_options_spec.rb +0 -46
- data/spec/integration/security/x_xss_protection_spec.rb +0 -46
- data/spec/integration/send_file_spec.rb +0 -51
- data/spec/integration/sessions_spec.rb +0 -247
- data/spec/integration/static_middleware_spec.rb +0 -21
- data/spec/integration/streaming_spec.rb +0 -41
- data/spec/integration/unsafe_send_file_spec.rb +0 -52
- data/spec/support/fixtures/hanami-plugin/Gemfile +0 -8
- data/spec/support/fixtures/hanami-plugin/README.md +0 -35
- data/spec/support/fixtures/hanami-plugin/Rakefile +0 -4
- data/spec/support/fixtures/hanami-plugin/bin/console +0 -15
- data/spec/support/fixtures/hanami-plugin/bin/setup +0 -8
- data/spec/support/fixtures/hanami-plugin/hanami-plugin.gemspec +0 -28
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/cli.rb +0 -19
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/version.rb +0 -7
- data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin.rb +0 -8
- data/spec/unit/hanami/routes_spec.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52462a1be45d338394f82872ac25bd8fc6e34f5b90991e74928342d0905d377d
|
4
|
+
data.tar.gz: 221af8ef1ba7993d6eb0678c0536513fca19f68b83bcf13d2fa5664747b83b98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2e0f16b7bee12601ebe28645be73219dd97647d4dc2ddfa47af25ac974092afa8d4b4ec849e0f7866e266c6dd7f39ddf31aa19b857083fb1841f19b98affdbf
|
7
|
+
data.tar.gz: 1b2ad0280e15291bba6fdf5efaf75bb10555eba655087ea53a9c5c7e8a5522335e0e07e0f2bf81f2b2c4ce638c14a58bbe2d8c827a792a5d2fc17111245bb75a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
The web, with simplicity.
|
4
4
|
|
5
|
+
## v2.0.0.beta3 - 2022-09-21
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- [Piotr Solnica] Simplify routes definition, by removing `routes` block from `config/routes.rb`
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
5
13
|
## v2.0.0.beta2 - 2022-08-16
|
6
14
|
|
7
15
|
### Added
|
@@ -25,6 +33,7 @@ The web, with simplicity.
|
|
25
33
|
Or by setting `HANAMI_SLICES=blog,shop` in the env.
|
26
34
|
|
27
35
|
You can also specify arbitrarily nested slices using dot delimiters. For example, if you have an `admin` slice with nested `shop` and `blog` slices, you can specify `config.slices = %w[admin.shop]` to only load the admin slice and its nested shop slice.
|
36
|
+
|
28
37
|
- [Tim Riley] Added `App.prepare_load_path`, which need only be called if you explicitly change your app's `config.root`. The `$LOAD_PATH` is otherwise still prepared automatically for the default `root` of `Dir.pwd`. [#1188]
|
29
38
|
- [Marc Busqué, Tim Riley] Added `Hanami.setup` to find and load your Hanami app file (expected at `config/app.rb`). This will search in the current directory, and will search upwards through parent directories until the app file is found. [#1197]
|
30
39
|
|
@@ -62,6 +71,7 @@ The web, with simplicity.
|
|
62
71
|
end
|
63
72
|
end
|
64
73
|
```
|
74
|
+
|
65
75
|
- [Tim Riley] Every slice has a distinct `Zeitwerk::Loader` instance at `Slice.autoloader`. This change enabled the autoloading within settings described above. [#1186]
|
66
76
|
- [Tim Riley] `Slice.settings` reader method has been removed. Access settings via `App["settings"]` or `Slice["settings"]` (after the slice has been prepared) instead. [#1186]
|
67
77
|
- [Tim Riley] dry-types is no longer a dependency specified in the gemspec. This is made available to generated app via a line in their `Gemfile` instead. [#1186]
|
@@ -133,7 +143,6 @@ The web, with simplicity.
|
|
133
143
|
- [Tim Riley] Removed `Hanami::Configuration::Router#routes_path`, and `#routes_class_name` [#1175]
|
134
144
|
- [Tim Riley] Make `Hanami::App` to inherit from `Hanami::Slice` [#1162]
|
135
145
|
|
136
|
-
|
137
146
|
## v2.0.0.alpha8 - 2022-05-19
|
138
147
|
|
139
148
|
### Added
|
@@ -5,8 +5,8 @@ require "dry/configurable"
|
|
5
5
|
module Hanami
|
6
6
|
class Configuration
|
7
7
|
# NullConfiguration can serve as a fallback configuration object when out-of-gem
|
8
|
-
# configuration objects are not available (specifically, when the
|
9
|
-
# hanami-view gems are not loaded)
|
8
|
+
# configuration objects are not available (specifically, when the
|
9
|
+
# hanami-controller, hanami-router or hanami-view gems are not loaded)
|
10
10
|
class NullConfiguration
|
11
11
|
include Dry::Configurable
|
12
12
|
end
|
data/lib/hanami/configuration.rb
CHANGED
@@ -9,7 +9,6 @@ require "pathname"
|
|
9
9
|
|
10
10
|
require_relative "constants"
|
11
11
|
require_relative "configuration/logger"
|
12
|
-
require_relative "configuration/router"
|
13
12
|
require_relative "configuration/sessions"
|
14
13
|
require_relative "settings/env_store"
|
15
14
|
require_relative "slice/routing/middleware/stack"
|
@@ -106,20 +105,22 @@ module Hanami
|
|
106
105
|
|
107
106
|
config.logger = Configuration::Logger.new(env: env, app_name: app_name)
|
108
107
|
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
# TODO: Make assets configuration dependent
|
109
|
+
require "hanami/assets/app_configuration"
|
110
|
+
@assets = Hanami::Assets::AppConfiguration.new
|
112
111
|
|
113
|
-
@actions = load_dependent_config("hanami
|
112
|
+
@actions = load_dependent_config("hanami-controller") {
|
114
113
|
require_relative "configuration/actions"
|
115
114
|
Actions.new
|
116
115
|
}
|
117
116
|
|
118
|
-
@
|
119
|
-
|
120
|
-
|
117
|
+
@router = load_dependent_config("hanami-router") {
|
118
|
+
require_relative "configuration/router"
|
119
|
+
@middleware = Slice::Routing::Middleware::Stack.new
|
120
|
+
Router.new(self)
|
121
|
+
}
|
121
122
|
|
122
|
-
@views = load_dependent_config("hanami
|
123
|
+
@views = load_dependent_config("hanami-view") {
|
123
124
|
require_relative "configuration/views"
|
124
125
|
Views.new
|
125
126
|
}
|
@@ -209,14 +210,13 @@ module Hanami
|
|
209
210
|
end
|
210
211
|
|
211
212
|
# @api private
|
212
|
-
def load_dependent_config(
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
NullConfiguration.new
|
213
|
+
def load_dependent_config(gem_name)
|
214
|
+
if Hanami.bundled?(gem_name)
|
215
|
+
yield
|
216
|
+
else
|
217
|
+
require_relative "configuration/null_configuration"
|
218
|
+
NullConfiguration.new
|
219
|
+
end
|
220
220
|
end
|
221
221
|
|
222
222
|
def method_missing(name, *args, &block)
|
data/lib/hanami/routes.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "hanami/slice/router"
|
4
|
+
|
3
5
|
module Hanami
|
4
6
|
# App routes
|
5
7
|
#
|
@@ -14,38 +16,63 @@ module Hanami
|
|
14
16
|
#
|
15
17
|
# module MyApp
|
16
18
|
# class Routes < Hanami::Routes
|
17
|
-
#
|
18
|
-
# root to: "home.show"
|
19
|
-
# end
|
19
|
+
# root to: "home.show"
|
20
20
|
# end
|
21
21
|
# end
|
22
22
|
#
|
23
|
-
# See {Hanami::Slice::Router} for the syntax allowed within the
|
24
|
-
# `define` block.
|
23
|
+
# See {Hanami::Slice::Router} for the syntax allowed within the `define` block.
|
25
24
|
#
|
26
25
|
# @see Hanami::Slice::Router
|
27
26
|
# @since 2.0.0
|
28
27
|
class Routes
|
29
|
-
# Defines app routes
|
30
|
-
#
|
31
|
-
# @yield DSL syntax to define app routes executed in the context
|
32
|
-
# of {Hanami::Slice::Router}
|
33
|
-
#
|
34
|
-
# @return [Proc]
|
35
|
-
def self.define(&block)
|
36
|
-
@_routes = block
|
37
|
-
end
|
38
|
-
|
39
28
|
# @api private
|
40
29
|
def self.routes
|
41
|
-
@
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
30
|
+
@routes ||= build_routes
|
31
|
+
end
|
32
|
+
|
33
|
+
class << self
|
34
|
+
# @api private
|
35
|
+
def build_routes(definitions = self.definitions)
|
36
|
+
return if definitions.empty?
|
37
|
+
|
38
|
+
proc do
|
39
|
+
definitions.each do |(name, args, kwargs, block)|
|
40
|
+
if block
|
41
|
+
public_send(name, *args, **kwargs, &block)
|
42
|
+
else
|
43
|
+
public_send(name, *args, **kwargs)
|
46
44
|
end
|
47
45
|
end
|
48
|
-
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# @api private
|
50
|
+
def definitions
|
51
|
+
@definitions ||= []
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
# @api private
|
57
|
+
def supported_methods
|
58
|
+
@supported_methods ||= Slice::Router.public_instance_methods
|
59
|
+
end
|
60
|
+
|
61
|
+
# @api private
|
62
|
+
def respond_to_missing?(name, include_private = false)
|
63
|
+
supported_methods.include?(name) || super
|
64
|
+
end
|
65
|
+
|
66
|
+
# Capture all method calls that are supported by the router DSL
|
67
|
+
# so that it can be evaluated lazily during configuration/boot
|
68
|
+
# process
|
69
|
+
#
|
70
|
+
# @api private
|
71
|
+
def method_missing(name, *args, **kwargs, &block)
|
72
|
+
return super unless respond_to?(name)
|
73
|
+
definitions << [name, args, kwargs, block]
|
74
|
+
self
|
75
|
+
end
|
49
76
|
end
|
50
77
|
end
|
51
78
|
end
|
data/lib/hanami/version.rb
CHANGED
File without changes
|
File without changes
|
@@ -14,12 +14,10 @@ RSpec.describe "App action / Routes", :app_integration do
|
|
14
14
|
write "config/routes.rb", <<~RUBY
|
15
15
|
module TestApp
|
16
16
|
class Routes < Hanami::Routes
|
17
|
-
|
18
|
-
root to: "home.index"
|
17
|
+
root to: "home.index"
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
19
|
+
slice :admin, at: "/admin" do
|
20
|
+
root to: "dashboard.index"
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/{new_integration → integration}/action/view_rendering/paired_view_inference_spec.rb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -64,10 +64,8 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
64
64
|
|
65
65
|
module TestApp
|
66
66
|
class Routes < Hanami::Routes
|
67
|
-
|
68
|
-
|
69
|
-
root to: "home.index"
|
70
|
-
end
|
67
|
+
slice :main, at: "/" do
|
68
|
+
root to: "home.index"
|
71
69
|
end
|
72
70
|
end
|
73
71
|
end
|
@@ -113,14 +111,12 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
113
111
|
|
114
112
|
module TestApp
|
115
113
|
class Routes < Hanami::Routes
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
use TestApp::Middlewares::AppendTwo, after: TestApp::Middlewares::AppendOne
|
114
|
+
slice :main, at: "/" do
|
115
|
+
use TestApp::Middlewares::AppendOne
|
116
|
+
use TestApp::Middlewares::Prepare, before: TestApp::Middlewares::AppendOne
|
117
|
+
use TestApp::Middlewares::AppendTwo, after: TestApp::Middlewares::AppendOne
|
121
118
|
|
122
|
-
|
123
|
-
end
|
119
|
+
root to: "home.index"
|
124
120
|
end
|
125
121
|
end
|
126
122
|
end
|
@@ -180,10 +176,8 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
180
176
|
|
181
177
|
module TestApp
|
182
178
|
class Routes < Hanami::Routes
|
183
|
-
|
184
|
-
|
185
|
-
root to: "home.index"
|
186
|
-
end
|
179
|
+
slice :main, at: "/" do
|
180
|
+
root to: "home.index"
|
187
181
|
end
|
188
182
|
end
|
189
183
|
end
|
@@ -24,11 +24,9 @@ RSpec.describe "Running a Rack app for a non-booted app", :app_integration do
|
|
24
24
|
|
25
25
|
module TestApp
|
26
26
|
class Routes < Hanami::Routes
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
get "/articles", to: "articles.index"
|
31
|
-
end
|
27
|
+
slice :main, at: "/" do
|
28
|
+
root to: "home.show"
|
29
|
+
get "/articles", to: "articles.index"
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -21,9 +21,7 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
21
21
|
write "config/routes.rb", <<~RUBY
|
22
22
|
module TestApp
|
23
23
|
class Routes < Hanami::Routes
|
24
|
-
|
25
|
-
root to: ->(env) { [200, {}, ["OK"]] }
|
26
|
-
end
|
24
|
+
root to: ->(env) { [200, {}, ["OK"]] }
|
27
25
|
end
|
28
26
|
end
|
29
27
|
RUBY
|
@@ -51,8 +49,7 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
51
49
|
write "config/routes.rb", <<~RUBY
|
52
50
|
module TestApp
|
53
51
|
class Routes < Hanami::Routes
|
54
|
-
|
55
|
-
end
|
52
|
+
root to: ->(env) { [200, {}, ["OK"]] }
|
56
53
|
end
|
57
54
|
end
|
58
55
|
RUBY
|
@@ -65,7 +62,7 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
65
62
|
|
66
63
|
logs = -> { Pathname(dir).join("test.log").realpath.read }
|
67
64
|
|
68
|
-
expect(logs.()).to match %r{GET
|
65
|
+
expect(logs.()).to match %r{GET 200 \d+ms 127.0.0.1 /}
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
@@ -89,8 +86,7 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
89
86
|
write "slices/main/config/routes.rb", <<~RUBY
|
90
87
|
module Main
|
91
88
|
class Routes < Hanami::Routes
|
92
|
-
|
93
|
-
end
|
89
|
+
root to: ->(env) { [200, {}, ["OK"]] }
|
94
90
|
end
|
95
91
|
end
|
96
92
|
RUBY
|
@@ -101,7 +97,7 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
101
97
|
|
102
98
|
logs = -> { Pathname(dir).join("test.log").realpath.read }
|
103
99
|
|
104
|
-
expect(logs.()).to match %r{GET
|
100
|
+
expect(logs.()).to match %r{GET 200 \d+ms 127.0.0.1 /}
|
105
101
|
end
|
106
102
|
end
|
107
103
|
end
|
@@ -121,20 +117,18 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
121
117
|
write "config/routes.rb", <<~RUBY
|
122
118
|
module TestApp
|
123
119
|
class Routes < Hanami::Routes
|
124
|
-
|
125
|
-
get "/health", to: "health.show"
|
120
|
+
get "/health", to: "health.show"
|
126
121
|
|
127
|
-
|
128
|
-
|
129
|
-
|
122
|
+
get "/inline" do
|
123
|
+
"Inline"
|
124
|
+
end
|
130
125
|
|
131
|
-
|
132
|
-
|
133
|
-
|
126
|
+
slice :main, at: "/" do
|
127
|
+
root to: "home.index"
|
128
|
+
end
|
134
129
|
|
135
|
-
|
136
|
-
|
137
|
-
end
|
130
|
+
slice :admin, at: "/admin" do
|
131
|
+
get "/dashboard", to: "dashboard.show"
|
138
132
|
end
|
139
133
|
end
|
140
134
|
end
|
@@ -228,12 +222,10 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
228
222
|
write "config/routes.rb", <<~RUBY
|
229
223
|
module TestApp
|
230
224
|
class Routes < Hanami::Routes
|
231
|
-
|
232
|
-
root to: "home.index"
|
225
|
+
root to: "home.index"
|
233
226
|
|
234
|
-
|
235
|
-
|
236
|
-
end
|
227
|
+
slice :main, at: "/" do
|
228
|
+
root to: "home.index"
|
237
229
|
end
|
238
230
|
end
|
239
231
|
end
|
@@ -295,12 +287,10 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
295
287
|
write "config/routes.rb", <<~RUBY
|
296
288
|
module TestApp
|
297
289
|
class Routes < Hanami::Routes
|
298
|
-
|
299
|
-
get "/feedbacks", to: "feedbacks.index"
|
290
|
+
get "/feedbacks", to: "feedbacks.index"
|
300
291
|
|
301
|
-
|
302
|
-
|
303
|
-
end
|
292
|
+
slice :api, at: "/api" do
|
293
|
+
get "/people", to: "people.index"
|
304
294
|
end
|
305
295
|
end
|
306
296
|
end
|
@@ -374,9 +364,7 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
374
364
|
write "config/routes.rb", <<~RUBY
|
375
365
|
module TestApp
|
376
366
|
class Routes < Hanami::Routes
|
377
|
-
|
378
|
-
get "/missing", to: "missing.action"
|
379
|
-
end
|
367
|
+
get "/missing", to: "missing.action"
|
380
368
|
end
|
381
369
|
end
|
382
370
|
RUBY
|
@@ -405,10 +393,8 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
405
393
|
write "config/routes.rb", <<~RUBY
|
406
394
|
module TestApp
|
407
395
|
class Routes < Hanami::Routes
|
408
|
-
|
409
|
-
|
410
|
-
get "/missing", to: "missing.action"
|
411
|
-
end
|
396
|
+
slice :admin, at: "/admin" do
|
397
|
+
get "/missing", to: "missing.action"
|
412
398
|
end
|
413
399
|
end
|
414
400
|
end
|
@@ -437,9 +423,7 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
437
423
|
write "config/routes.rb", <<~RUBY
|
438
424
|
module TestApp
|
439
425
|
class Routes < Hanami::Routes
|
440
|
-
|
441
|
-
get "/missing", to: "missing.action"
|
442
|
-
end
|
426
|
+
get "/missing", to: "missing.action"
|
443
427
|
end
|
444
428
|
end
|
445
429
|
RUBY
|
@@ -470,10 +454,8 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
470
454
|
write "config/routes.rb", <<~RUBY
|
471
455
|
module TestApp
|
472
456
|
class Routes < Hanami::Routes
|
473
|
-
|
474
|
-
|
475
|
-
get "/missing", to: "missing.action"
|
476
|
-
end
|
457
|
+
slice :admin, at: "/admin" do
|
458
|
+
get "/missing", to: "missing.action"
|
477
459
|
end
|
478
460
|
end
|
479
461
|
end
|
@@ -504,10 +486,8 @@ RSpec.describe "Hanami web app", :app_integration do
|
|
504
486
|
write "config/routes.rb", <<~RUBY
|
505
487
|
module TestApp
|
506
488
|
class Routes < Hanami::Routes
|
507
|
-
|
508
|
-
|
509
|
-
get "/bar", to: "bar.index"
|
510
|
-
end
|
489
|
+
slice :foo, at: "/foo" do
|
490
|
+
get "/bar", to: "bar.index"
|
511
491
|
end
|
512
492
|
end
|
513
493
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -55,6 +55,26 @@ RSpec.describe "Hanami setup", :app_integration do
|
|
55
55
|
|
56
56
|
expect { setup }.not_to raise_error
|
57
57
|
end
|
58
|
+
|
59
|
+
%w[hanami-view hanami-actions hanami-router].each do |gem_name|
|
60
|
+
it "works when #{gem_name} gem is not bundled" do
|
61
|
+
allow(Hanami).to receive(:bundled?).and_call_original
|
62
|
+
expect(Hanami).to receive(:bundled?).with("hanami-router").and_return(false)
|
63
|
+
|
64
|
+
with_tmp_directory(Dir.mktmpdir) do
|
65
|
+
write "config/app.rb", <<~RUBY
|
66
|
+
require "hanami"
|
67
|
+
|
68
|
+
module TestApp
|
69
|
+
class App < Hanami::App
|
70
|
+
end
|
71
|
+
end
|
72
|
+
RUBY
|
73
|
+
|
74
|
+
expect { setup }.to change { Hanami.app? }.to true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
58
78
|
end
|
59
79
|
|
60
80
|
describe "using hanami/setup require" do
|
@@ -27,10 +27,8 @@ RSpec.describe "Slices / External slices", :app_integration do
|
|
27
27
|
|
28
28
|
module TestApp
|
29
29
|
class Routes < Hanami::Routes
|
30
|
-
|
31
|
-
|
32
|
-
root to: "test_action"
|
33
|
-
end
|
30
|
+
slice :external, at: "/" do
|
31
|
+
root to: "test_action"
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
File without changes
|
File without changes
|
@@ -44,9 +44,7 @@ RSpec.describe "Slices / Slice routing", :app_integration do
|
|
44
44
|
|
45
45
|
module TestApp
|
46
46
|
class Routes < Hanami::Routes
|
47
|
-
|
48
|
-
get "home", to: "home.show", as: :home
|
49
|
-
end
|
47
|
+
get "home", to: "home.show", as: :home
|
50
48
|
end
|
51
49
|
end
|
52
50
|
RUBY
|
@@ -79,9 +77,7 @@ RSpec.describe "Slices / Slice routing", :app_integration do
|
|
79
77
|
|
80
78
|
module Main
|
81
79
|
class Routes < Hanami::Routes
|
82
|
-
|
83
|
-
get "home", to: "home.show", as: :home
|
84
|
-
end
|
80
|
+
get "home", to: "home.show", as: :home
|
85
81
|
end
|
86
82
|
end
|
87
83
|
RUBY
|
@@ -130,11 +126,9 @@ RSpec.describe "Slices / Slice routing", :app_integration do
|
|
130
126
|
write "config/routes.rb", <<~'RUBY'
|
131
127
|
module TestApp
|
132
128
|
class Routes < Hanami::Routes
|
133
|
-
|
134
|
-
root to: "home.show"
|
129
|
+
root to: "home.show"
|
135
130
|
|
136
|
-
|
137
|
-
end
|
131
|
+
slice :main, at: "/main"
|
138
132
|
end
|
139
133
|
end
|
140
134
|
RUBY
|
@@ -158,9 +152,7 @@ RSpec.describe "Slices / Slice routing", :app_integration do
|
|
158
152
|
write "slices/main/config/routes.rb", <<~'RUBY'
|
159
153
|
module Main
|
160
154
|
class Routes < Hanami::Routes
|
161
|
-
|
162
|
-
root to: "home.show"
|
163
|
-
end
|
155
|
+
root to: "home.show"
|
164
156
|
end
|
165
157
|
end
|
166
158
|
RUBY
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|