hanami 2.0.3 → 2.1.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -2
  3. data/LICENSE.md +1 -1
  4. data/README.md +26 -10
  5. data/hanami.gemspec +2 -2
  6. data/lib/hanami/app.rb +5 -0
  7. data/lib/hanami/config/actions.rb +4 -11
  8. data/lib/hanami/config/assets.rb +84 -0
  9. data/lib/hanami/config/null_config.rb +3 -0
  10. data/lib/hanami/config/views.rb +0 -4
  11. data/lib/hanami/config.rb +71 -5
  12. data/lib/hanami/extensions/action/slice_configured_action.rb +15 -7
  13. data/lib/hanami/extensions/action.rb +8 -6
  14. data/lib/hanami/extensions/router/errors.rb +58 -0
  15. data/lib/hanami/extensions/view/context.rb +129 -60
  16. data/lib/hanami/extensions/view/part.rb +26 -0
  17. data/lib/hanami/extensions/view/scope.rb +26 -0
  18. data/lib/hanami/extensions/view/slice_configured_context.rb +0 -2
  19. data/lib/hanami/extensions/view/slice_configured_helpers.rb +44 -0
  20. data/lib/hanami/extensions/view/slice_configured_view.rb +106 -21
  21. data/lib/hanami/extensions/view/standard_helpers.rb +18 -0
  22. data/lib/hanami/extensions.rb +10 -3
  23. data/lib/hanami/helpers/assets_helper.rb +752 -0
  24. data/lib/hanami/helpers/form_helper/form_builder.rb +1391 -0
  25. data/lib/hanami/helpers/form_helper/values.rb +75 -0
  26. data/lib/hanami/helpers/form_helper.rb +213 -0
  27. data/lib/hanami/middleware/assets.rb +21 -0
  28. data/lib/hanami/middleware/public_errors_app.rb +75 -0
  29. data/lib/hanami/middleware/render_errors.rb +90 -0
  30. data/lib/hanami/providers/assets.rb +44 -0
  31. data/lib/hanami/rake_tasks.rb +19 -18
  32. data/lib/hanami/settings.rb +1 -1
  33. data/lib/hanami/slice.rb +48 -2
  34. data/lib/hanami/slice_configurable.rb +3 -2
  35. data/lib/hanami/version.rb +1 -1
  36. data/lib/hanami/web/rack_logger.rb +1 -1
  37. data/lib/hanami.rb +3 -3
  38. data/spec/integration/action/view_rendering/view_context_spec.rb +221 -0
  39. data/spec/integration/action/view_rendering_spec.rb +0 -18
  40. data/spec/integration/assets/assets_spec.rb +101 -0
  41. data/spec/integration/assets/serve_static_assets_spec.rb +152 -0
  42. data/spec/integration/logging/exception_logging_spec.rb +115 -0
  43. data/spec/integration/logging/notifications_spec.rb +68 -0
  44. data/spec/integration/logging/request_logging_spec.rb +128 -0
  45. data/spec/integration/rack_app/middleware_spec.rb +22 -22
  46. data/spec/integration/rack_app/rack_app_spec.rb +3 -220
  47. data/spec/integration/rake_tasks_spec.rb +107 -0
  48. data/spec/integration/view/config/default_context_spec.rb +149 -0
  49. data/spec/integration/view/{inflector_spec.rb → config/inflector_spec.rb} +1 -1
  50. data/spec/integration/view/config/part_class_spec.rb +147 -0
  51. data/spec/integration/view/config/part_namespace_spec.rb +103 -0
  52. data/spec/integration/view/config/paths_spec.rb +119 -0
  53. data/spec/integration/view/config/scope_class_spec.rb +147 -0
  54. data/spec/integration/view/config/scope_namespace_spec.rb +103 -0
  55. data/spec/integration/view/config/template_spec.rb +38 -0
  56. data/spec/integration/view/context/assets_spec.rb +3 -9
  57. data/spec/integration/view/context/request_spec.rb +3 -7
  58. data/spec/integration/view/helpers/form_helper_spec.rb +174 -0
  59. data/spec/integration/view/helpers/part_helpers_spec.rb +124 -0
  60. data/spec/integration/view/helpers/scope_helpers_spec.rb +84 -0
  61. data/spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb +162 -0
  62. data/spec/integration/view/helpers/user_defined_helpers/scope_helpers_spec.rb +119 -0
  63. data/spec/integration/view/slice_configuration_spec.rb +9 -9
  64. data/spec/integration/web/render_detailed_errors_spec.rb +107 -0
  65. data/spec/integration/web/render_errors_spec.rb +242 -0
  66. data/spec/spec_helper.rb +1 -1
  67. data/spec/support/app_integration.rb +46 -2
  68. data/spec/support/matchers.rb +32 -0
  69. data/spec/unit/hanami/config/actions/content_security_policy_spec.rb +24 -36
  70. data/spec/unit/hanami/config/actions/csrf_protection_spec.rb +4 -3
  71. data/spec/unit/hanami/config/actions/default_values_spec.rb +3 -6
  72. data/spec/unit/hanami/config/render_detailed_errors_spec.rb +25 -0
  73. data/spec/unit/hanami/config/render_errors_spec.rb +25 -0
  74. data/spec/unit/hanami/config/views_spec.rb +0 -18
  75. data/spec/unit/hanami/env_spec.rb +11 -25
  76. data/spec/unit/hanami/extensions/view/context_spec.rb +59 -0
  77. data/spec/unit/hanami/helpers/assets_helper/asset_url_spec.rb +109 -0
  78. data/spec/unit/hanami/helpers/assets_helper/audio_tag_spec.rb +132 -0
  79. data/spec/unit/hanami/helpers/assets_helper/favicon_link_tag_spec.rb +91 -0
  80. data/spec/unit/hanami/helpers/assets_helper/image_tag_spec.rb +92 -0
  81. data/spec/unit/hanami/helpers/assets_helper/javascript_tag_spec.rb +143 -0
  82. data/spec/unit/hanami/helpers/assets_helper/stylesheet_link_tag_spec.rb +126 -0
  83. data/spec/unit/hanami/helpers/assets_helper/video_tag_spec.rb +132 -0
  84. data/spec/unit/hanami/helpers/form_helper_spec.rb +2826 -0
  85. data/spec/unit/hanami/router/errors/not_allowed_error_spec.rb +27 -0
  86. data/spec/unit/hanami/router/errors/not_found_error_spec.rb +22 -0
  87. data/spec/unit/hanami/slice_configurable_spec.rb +18 -0
  88. data/spec/unit/hanami/version_spec.rb +1 -1
  89. data/spec/unit/hanami/web/rack_logger_spec.rb +1 -1
  90. metadata +95 -35
  91. data/lib/hanami/assets/app_config.rb +0 -61
  92. data/lib/hanami/assets/config.rb +0 -53
  93. data/spec/integration/action/view_integration_spec.rb +0 -165
  94. data/spec/integration/view/part_namespace_spec.rb +0 -96
  95. data/spec/integration/view/path_spec.rb +0 -56
  96. data/spec/integration/view/template_spec.rb +0 -68
  97. data/spec/isolation/hanami/application/already_configured_spec.rb +0 -19
  98. data/spec/isolation/hanami/application/inherit_anonymous_class_spec.rb +0 -10
  99. data/spec/isolation/hanami/application/inherit_concrete_class_spec.rb +0 -14
  100. data/spec/isolation/hanami/application/not_configured_spec.rb +0 -9
  101. data/spec/isolation/hanami/application/routes/configured_spec.rb +0 -44
  102. data/spec/isolation/hanami/application/routes/not_configured_spec.rb +0 -16
  103. data/spec/isolation/hanami/boot/success_spec.rb +0 -50
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/router"
4
+ require "hanami/extensions/router/errors"
5
+
6
+ RSpec.describe(Hanami::Router::NotAllowedError) do
7
+ subject(:error) { described_class.new(env, allowed_methods) }
8
+
9
+ let(:env) { Rack::MockRequest.env_for("http://example.com/example", method: "POST") }
10
+ let(:allowed_methods) { ["GET", "HEAD"] }
11
+
12
+ it "is a Hanami::Router::Error" do
13
+ expect(error.class).to be < Hanami::Router::Error
14
+ end
15
+
16
+ it "returns a relevant message" do
17
+ expect(error.to_s).to eq "Only GET, HEAD requests are allowed at /example"
18
+ end
19
+
20
+ it "returns the env" do
21
+ expect(error.env).to be env
22
+ end
23
+
24
+ it "returns the allowed methods" do
25
+ expect(error.allowed_methods).to be allowed_methods
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/router"
4
+ require "hanami/extensions/router/errors"
5
+
6
+ RSpec.describe(Hanami::Router::NotFoundError) do
7
+ subject(:error) { described_class.new(env) }
8
+
9
+ let(:env) { Rack::MockRequest.env_for("http://example.com/example", method: "GET") }
10
+
11
+ it "is a Hanami::Router::Error" do
12
+ expect(error.class).to be < Hanami::Router::Error
13
+ end
14
+
15
+ it "returns a relevant message" do
16
+ expect(error.to_s).to eq "No route found for GET /example"
17
+ end
18
+
19
+ it "returns the env" do
20
+ expect(error.env).to be env
21
+ end
22
+ end
@@ -72,6 +72,24 @@ RSpec.describe Hanami::SliceConfigurable, :app_integration do
72
72
  end
73
73
  end
74
74
 
75
+ context "subclass inside slice with name overlapping another slice" do
76
+ let(:app_modules) { super() << :ExternalAdmin }
77
+
78
+ before do
79
+ TestApp::App.register_slice :external_admin
80
+
81
+ module ExternalAdmin
82
+ class MySubclass < TestApp::BaseClass; end
83
+ end
84
+ end
85
+
86
+ subject(:subclass) { ExternalAdmin::MySubclass }
87
+
88
+ it "calls `configure_for_slice` with the correct matching slice" do
89
+ expect(subclass.traces).to eq [ExternalAdmin::Slice]
90
+ end
91
+ end
92
+
75
93
  context "class inside app" do
76
94
  before do
77
95
  module TestApp
@@ -2,6 +2,6 @@
2
2
 
3
3
  RSpec.describe "Hanami::VERSION" do
4
4
  it "returns current version" do
5
- expect(Hanami::VERSION).to eq("2.0.3")
5
+ expect(Hanami::VERSION).to eq("2.1.0.beta2")
6
6
  end
7
7
  end
@@ -42,7 +42,7 @@ RSpec.describe Hanami::Web::RackLogger do
42
42
  verb = "POST"
43
43
 
44
44
  env = Rack::MockRequest.env_for(path, method: verb)
45
- env["Content-Length"] = content_length
45
+ env["CONTENT_LENGTH"] = content_length
46
46
  env["REMOTE_ADDR"] = ip
47
47
 
48
48
  params = {"user" => {"password" => "secret"}}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-01 00:00:00.000000000 Z
11
+ date: 2023-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -162,28 +162,28 @@ dependencies:
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: '2.0'
165
+ version: 2.1.beta
166
166
  type: :runtime
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '2.0'
172
+ version: 2.1.beta
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: hanami-utils
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
177
  - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: '2.0'
179
+ version: 2.1.beta
180
180
  type: :runtime
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
184
  - - "~>"
185
185
  - !ruby/object:Gem::Version
186
- version: '2.0'
186
+ version: 2.1.beta
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: zeitwerk
189
189
  requirement: !ruby/object:Gem::Requirement
@@ -255,14 +255,13 @@ files:
255
255
  - hanami.gemspec
256
256
  - lib/hanami.rb
257
257
  - lib/hanami/app.rb
258
- - lib/hanami/assets/app_config.rb
259
- - lib/hanami/assets/config.rb
260
258
  - lib/hanami/boot.rb
261
259
  - lib/hanami/config.rb
262
260
  - lib/hanami/config/actions.rb
263
261
  - lib/hanami/config/actions/content_security_policy.rb
264
262
  - lib/hanami/config/actions/cookies.rb
265
263
  - lib/hanami/config/actions/sessions.rb
264
+ - lib/hanami/config/assets.rb
266
265
  - lib/hanami/config/logger.rb
267
266
  - lib/hanami/config/null_config.rb
268
267
  - lib/hanami/config/router.rb
@@ -273,12 +272,25 @@ files:
273
272
  - lib/hanami/extensions.rb
274
273
  - lib/hanami/extensions/action.rb
275
274
  - lib/hanami/extensions/action/slice_configured_action.rb
275
+ - lib/hanami/extensions/router/errors.rb
276
276
  - lib/hanami/extensions/view.rb
277
277
  - lib/hanami/extensions/view/context.rb
278
+ - lib/hanami/extensions/view/part.rb
279
+ - lib/hanami/extensions/view/scope.rb
278
280
  - lib/hanami/extensions/view/slice_configured_context.rb
281
+ - lib/hanami/extensions/view/slice_configured_helpers.rb
279
282
  - lib/hanami/extensions/view/slice_configured_view.rb
283
+ - lib/hanami/extensions/view/standard_helpers.rb
284
+ - lib/hanami/helpers/assets_helper.rb
285
+ - lib/hanami/helpers/form_helper.rb
286
+ - lib/hanami/helpers/form_helper/form_builder.rb
287
+ - lib/hanami/helpers/form_helper/values.rb
288
+ - lib/hanami/middleware/assets.rb
289
+ - lib/hanami/middleware/public_errors_app.rb
290
+ - lib/hanami/middleware/render_errors.rb
280
291
  - lib/hanami/port.rb
281
292
  - lib/hanami/prepare.rb
293
+ - lib/hanami/providers/assets.rb
282
294
  - lib/hanami/providers/inflector.rb
283
295
  - lib/hanami/providers/logger.rb
284
296
  - lib/hanami/providers/rack.rb
@@ -305,10 +317,12 @@ files:
305
317
  - spec/integration/action/routes_spec.rb
306
318
  - spec/integration/action/sessions_spec.rb
307
319
  - spec/integration/action/slice_configuration_spec.rb
308
- - spec/integration/action/view_integration_spec.rb
309
320
  - spec/integration/action/view_rendering/automatic_rendering_spec.rb
310
321
  - spec/integration/action/view_rendering/paired_view_inference_spec.rb
322
+ - spec/integration/action/view_rendering/view_context_spec.rb
311
323
  - spec/integration/action/view_rendering_spec.rb
324
+ - spec/integration/assets/assets_spec.rb
325
+ - spec/integration/assets/serve_static_assets_spec.rb
312
326
  - spec/integration/code_loading/loading_from_app_spec.rb
313
327
  - spec/integration/code_loading/loading_from_lib_spec.rb
314
328
  - spec/integration/code_loading/loading_from_slice_spec.rb
@@ -323,10 +337,14 @@ files:
323
337
  - spec/integration/container/standard_providers/rack_provider_spec.rb
324
338
  - spec/integration/container/standard_providers_spec.rb
325
339
  - spec/integration/dotenv_loading_spec.rb
340
+ - spec/integration/logging/exception_logging_spec.rb
341
+ - spec/integration/logging/notifications_spec.rb
342
+ - spec/integration/logging/request_logging_spec.rb
326
343
  - spec/integration/rack_app/body_parser_spec.rb
327
344
  - spec/integration/rack_app/middleware_spec.rb
328
345
  - spec/integration/rack_app/non_booted_rack_app_spec.rb
329
346
  - spec/integration/rack_app/rack_app_spec.rb
347
+ - spec/integration/rake_tasks_spec.rb
330
348
  - spec/integration/settings/access_in_slice_class_body_spec.rb
331
349
  - spec/integration/settings/access_to_constants_spec.rb
332
350
  - spec/integration/settings/loading_from_env_spec.rb
@@ -340,27 +358,32 @@ files:
340
358
  - spec/integration/slices/slice_registrations_spec.rb
341
359
  - spec/integration/slices/slice_routing_spec.rb
342
360
  - spec/integration/slices_spec.rb
361
+ - spec/integration/view/config/default_context_spec.rb
362
+ - spec/integration/view/config/inflector_spec.rb
363
+ - spec/integration/view/config/part_class_spec.rb
364
+ - spec/integration/view/config/part_namespace_spec.rb
365
+ - spec/integration/view/config/paths_spec.rb
366
+ - spec/integration/view/config/scope_class_spec.rb
367
+ - spec/integration/view/config/scope_namespace_spec.rb
368
+ - spec/integration/view/config/template_spec.rb
343
369
  - spec/integration/view/context/assets_spec.rb
344
370
  - spec/integration/view/context/inflector_spec.rb
345
371
  - spec/integration/view/context/request_spec.rb
346
372
  - spec/integration/view/context/routes_spec.rb
347
373
  - spec/integration/view/context/settings_spec.rb
348
- - spec/integration/view/inflector_spec.rb
349
- - spec/integration/view/part_namespace_spec.rb
350
- - spec/integration/view/path_spec.rb
374
+ - spec/integration/view/helpers/form_helper_spec.rb
375
+ - spec/integration/view/helpers/part_helpers_spec.rb
376
+ - spec/integration/view/helpers/scope_helpers_spec.rb
377
+ - spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb
378
+ - spec/integration/view/helpers/user_defined_helpers/scope_helpers_spec.rb
351
379
  - spec/integration/view/slice_configuration_spec.rb
352
- - spec/integration/view/template_spec.rb
353
380
  - spec/integration/view/views_spec.rb
354
- - spec/isolation/hanami/application/already_configured_spec.rb
355
- - spec/isolation/hanami/application/inherit_anonymous_class_spec.rb
356
- - spec/isolation/hanami/application/inherit_concrete_class_spec.rb
357
- - spec/isolation/hanami/application/not_configured_spec.rb
358
- - spec/isolation/hanami/application/routes/configured_spec.rb
359
- - spec/isolation/hanami/application/routes/not_configured_spec.rb
360
- - spec/isolation/hanami/boot/success_spec.rb
381
+ - spec/integration/web/render_detailed_errors_spec.rb
382
+ - spec/integration/web/render_errors_spec.rb
361
383
  - spec/spec_helper.rb
362
384
  - spec/support/app_integration.rb
363
385
  - spec/support/coverage.rb
386
+ - spec/support/matchers.rb
364
387
  - spec/support/rspec.rb
365
388
  - spec/support/shared_examples/cli/generate/app.rb
366
389
  - spec/support/shared_examples/cli/generate/migration.rb
@@ -375,11 +398,24 @@ files:
375
398
  - spec/unit/hanami/config/base_url_spec.rb
376
399
  - spec/unit/hanami/config/inflector_spec.rb
377
400
  - spec/unit/hanami/config/logger_spec.rb
401
+ - spec/unit/hanami/config/render_detailed_errors_spec.rb
402
+ - spec/unit/hanami/config/render_errors_spec.rb
378
403
  - spec/unit/hanami/config/router_spec.rb
379
404
  - spec/unit/hanami/config/slices_spec.rb
380
405
  - spec/unit/hanami/config/views_spec.rb
381
406
  - spec/unit/hanami/env_spec.rb
407
+ - spec/unit/hanami/extensions/view/context_spec.rb
408
+ - spec/unit/hanami/helpers/assets_helper/asset_url_spec.rb
409
+ - spec/unit/hanami/helpers/assets_helper/audio_tag_spec.rb
410
+ - spec/unit/hanami/helpers/assets_helper/favicon_link_tag_spec.rb
411
+ - spec/unit/hanami/helpers/assets_helper/image_tag_spec.rb
412
+ - spec/unit/hanami/helpers/assets_helper/javascript_tag_spec.rb
413
+ - spec/unit/hanami/helpers/assets_helper/stylesheet_link_tag_spec.rb
414
+ - spec/unit/hanami/helpers/assets_helper/video_tag_spec.rb
415
+ - spec/unit/hanami/helpers/form_helper_spec.rb
382
416
  - spec/unit/hanami/port_spec.rb
417
+ - spec/unit/hanami/router/errors/not_allowed_error_spec.rb
418
+ - spec/unit/hanami/router/errors/not_found_error_spec.rb
383
419
  - spec/unit/hanami/settings/env_store_spec.rb
384
420
  - spec/unit/hanami/settings_spec.rb
385
421
  - spec/unit/hanami/slice_configurable_spec.rb
@@ -404,11 +440,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
404
440
  version: '3.0'
405
441
  required_rubygems_version: !ruby/object:Gem::Requirement
406
442
  requirements:
407
- - - ">="
443
+ - - ">"
408
444
  - !ruby/object:Gem::Version
409
- version: '0'
445
+ version: 1.3.1
410
446
  requirements: []
411
- rubygems_version: 3.4.5
447
+ rubygems_version: 3.4.13
412
448
  signing_key:
413
449
  specification_version: 4
414
450
  summary: The web, with simplicity
@@ -419,10 +455,12 @@ test_files:
419
455
  - spec/integration/action/routes_spec.rb
420
456
  - spec/integration/action/sessions_spec.rb
421
457
  - spec/integration/action/slice_configuration_spec.rb
422
- - spec/integration/action/view_integration_spec.rb
423
458
  - spec/integration/action/view_rendering/automatic_rendering_spec.rb
424
459
  - spec/integration/action/view_rendering/paired_view_inference_spec.rb
460
+ - spec/integration/action/view_rendering/view_context_spec.rb
425
461
  - spec/integration/action/view_rendering_spec.rb
462
+ - spec/integration/assets/assets_spec.rb
463
+ - spec/integration/assets/serve_static_assets_spec.rb
426
464
  - spec/integration/code_loading/loading_from_app_spec.rb
427
465
  - spec/integration/code_loading/loading_from_lib_spec.rb
428
466
  - spec/integration/code_loading/loading_from_slice_spec.rb
@@ -437,10 +475,14 @@ test_files:
437
475
  - spec/integration/container/standard_providers/rack_provider_spec.rb
438
476
  - spec/integration/container/standard_providers_spec.rb
439
477
  - spec/integration/dotenv_loading_spec.rb
478
+ - spec/integration/logging/exception_logging_spec.rb
479
+ - spec/integration/logging/notifications_spec.rb
480
+ - spec/integration/logging/request_logging_spec.rb
440
481
  - spec/integration/rack_app/body_parser_spec.rb
441
482
  - spec/integration/rack_app/middleware_spec.rb
442
483
  - spec/integration/rack_app/non_booted_rack_app_spec.rb
443
484
  - spec/integration/rack_app/rack_app_spec.rb
485
+ - spec/integration/rake_tasks_spec.rb
444
486
  - spec/integration/settings/access_in_slice_class_body_spec.rb
445
487
  - spec/integration/settings/access_to_constants_spec.rb
446
488
  - spec/integration/settings/loading_from_env_spec.rb
@@ -454,27 +496,32 @@ test_files:
454
496
  - spec/integration/slices/slice_registrations_spec.rb
455
497
  - spec/integration/slices/slice_routing_spec.rb
456
498
  - spec/integration/slices_spec.rb
499
+ - spec/integration/view/config/default_context_spec.rb
500
+ - spec/integration/view/config/inflector_spec.rb
501
+ - spec/integration/view/config/part_class_spec.rb
502
+ - spec/integration/view/config/part_namespace_spec.rb
503
+ - spec/integration/view/config/paths_spec.rb
504
+ - spec/integration/view/config/scope_class_spec.rb
505
+ - spec/integration/view/config/scope_namespace_spec.rb
506
+ - spec/integration/view/config/template_spec.rb
457
507
  - spec/integration/view/context/assets_spec.rb
458
508
  - spec/integration/view/context/inflector_spec.rb
459
509
  - spec/integration/view/context/request_spec.rb
460
510
  - spec/integration/view/context/routes_spec.rb
461
511
  - spec/integration/view/context/settings_spec.rb
462
- - spec/integration/view/inflector_spec.rb
463
- - spec/integration/view/part_namespace_spec.rb
464
- - spec/integration/view/path_spec.rb
512
+ - spec/integration/view/helpers/form_helper_spec.rb
513
+ - spec/integration/view/helpers/part_helpers_spec.rb
514
+ - spec/integration/view/helpers/scope_helpers_spec.rb
515
+ - spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb
516
+ - spec/integration/view/helpers/user_defined_helpers/scope_helpers_spec.rb
465
517
  - spec/integration/view/slice_configuration_spec.rb
466
- - spec/integration/view/template_spec.rb
467
518
  - spec/integration/view/views_spec.rb
468
- - spec/isolation/hanami/application/already_configured_spec.rb
469
- - spec/isolation/hanami/application/inherit_anonymous_class_spec.rb
470
- - spec/isolation/hanami/application/inherit_concrete_class_spec.rb
471
- - spec/isolation/hanami/application/not_configured_spec.rb
472
- - spec/isolation/hanami/application/routes/configured_spec.rb
473
- - spec/isolation/hanami/application/routes/not_configured_spec.rb
474
- - spec/isolation/hanami/boot/success_spec.rb
519
+ - spec/integration/web/render_detailed_errors_spec.rb
520
+ - spec/integration/web/render_errors_spec.rb
475
521
  - spec/spec_helper.rb
476
522
  - spec/support/app_integration.rb
477
523
  - spec/support/coverage.rb
524
+ - spec/support/matchers.rb
478
525
  - spec/support/rspec.rb
479
526
  - spec/support/shared_examples/cli/generate/app.rb
480
527
  - spec/support/shared_examples/cli/generate/migration.rb
@@ -489,11 +536,24 @@ test_files:
489
536
  - spec/unit/hanami/config/base_url_spec.rb
490
537
  - spec/unit/hanami/config/inflector_spec.rb
491
538
  - spec/unit/hanami/config/logger_spec.rb
539
+ - spec/unit/hanami/config/render_detailed_errors_spec.rb
540
+ - spec/unit/hanami/config/render_errors_spec.rb
492
541
  - spec/unit/hanami/config/router_spec.rb
493
542
  - spec/unit/hanami/config/slices_spec.rb
494
543
  - spec/unit/hanami/config/views_spec.rb
495
544
  - spec/unit/hanami/env_spec.rb
545
+ - spec/unit/hanami/extensions/view/context_spec.rb
546
+ - spec/unit/hanami/helpers/assets_helper/asset_url_spec.rb
547
+ - spec/unit/hanami/helpers/assets_helper/audio_tag_spec.rb
548
+ - spec/unit/hanami/helpers/assets_helper/favicon_link_tag_spec.rb
549
+ - spec/unit/hanami/helpers/assets_helper/image_tag_spec.rb
550
+ - spec/unit/hanami/helpers/assets_helper/javascript_tag_spec.rb
551
+ - spec/unit/hanami/helpers/assets_helper/stylesheet_link_tag_spec.rb
552
+ - spec/unit/hanami/helpers/assets_helper/video_tag_spec.rb
553
+ - spec/unit/hanami/helpers/form_helper_spec.rb
496
554
  - spec/unit/hanami/port_spec.rb
555
+ - spec/unit/hanami/router/errors/not_allowed_error_spec.rb
556
+ - spec/unit/hanami/router/errors/not_found_error_spec.rb
497
557
  - spec/unit/hanami/settings/env_store_spec.rb
498
558
  - spec/unit/hanami/settings_spec.rb
499
559
  - spec/unit/hanami/slice_configurable_spec.rb
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/configurable"
4
-
5
- module Hanami
6
- # @api private
7
- module Assets
8
- # App config for assets.
9
- #
10
- # This is NOT RELEASED as of 2.0.0.
11
- #
12
- # @api private
13
- class AppConfig
14
- include Dry::Configurable
15
-
16
- attr_reader :base_config
17
- protected :base_config
18
-
19
- setting :server_url, default: "http://localhost:8080"
20
-
21
- def initialize(*)
22
- super
23
-
24
- @base_config = Assets::Config.new
25
- end
26
-
27
- def initialize_copy(source)
28
- super
29
- @base_config = source.base_config.dup
30
- end
31
-
32
- def finalize!
33
- end
34
-
35
- # Returns the list of available settings
36
- #
37
- # @return [Set]
38
- #
39
- # @api private
40
- def settings
41
- base_config.settings + self.class.settings
42
- end
43
-
44
- private
45
-
46
- def method_missing(name, *args, &block)
47
- if config.respond_to?(name)
48
- config.public_send(name, *args, &block)
49
- elsif base_config.respond_to?(name)
50
- base_config.public_send(name, *args, &block)
51
- else
52
- super
53
- end
54
- end
55
-
56
- def respond_to_missing?(name, _incude_all = false)
57
- config.respond_to?(name) || base_config.respond_to?(name) || super
58
- end
59
- end
60
- end
61
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/configurable"
4
-
5
- module Hanami
6
- module Assets
7
- # App config for assets.
8
- #
9
- # This is NOT RELEASED as of 2.0.0.
10
- #
11
- # @api private
12
- class Config
13
- include Dry::Configurable
14
-
15
- # Initialize the Config
16
- #
17
- # @yield [config] the config object
18
- #
19
- # @return [Config]
20
- #
21
- # @since 2.0.0
22
- # @api private
23
- def initialize(*)
24
- super
25
- yield self if block_given?
26
- end
27
-
28
- # Returns the list of available settings
29
- #
30
- # @return [Set]
31
- #
32
- # @since 2.0.0
33
- # @api private
34
- def settings
35
- self.class.settings
36
- end
37
-
38
- private
39
-
40
- def method_missing(name, *args, &block)
41
- if config.respond_to?(name)
42
- config.public_send(name, *args, &block)
43
- else
44
- super
45
- end
46
- end
47
-
48
- def respond_to_missing?(name, _incude_all = false)
49
- config.respond_to?(name) || super
50
- end
51
- end
52
- end
53
- end
@@ -1,165 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe "App action / View integration", :app_integration do
4
- before do
5
- module TestApp
6
- class App < Hanami::App
7
- end
8
- end
9
-
10
- Hanami.app.instance_eval(&app_hook) if respond_to?(:app_hook)
11
- Hanami.app.prepare
12
-
13
- module TestApp
14
- class Action < Hanami::Action; end
15
- end
16
-
17
- module TestApp
18
- module Actions
19
- module Articles
20
- class Index < TestApp::Action; end
21
- end
22
- end
23
- end
24
- end
25
-
26
- let(:action_class) { TestApp::Actions::Articles::Index }
27
- subject(:action) { action_class.new(**action_args) }
28
- let(:action_args) { {} }
29
-
30
- describe "#view_context" do
31
- subject(:view_context) { action.view_context }
32
-
33
- context "Explicitly injected view context" do
34
- let(:view_context) { double(:view_context) }
35
- let(:action_args) { {view_context: view_context} }
36
-
37
- it "returns the injected object" do
38
- is_expected.to eql view_context
39
- end
40
- end
41
-
42
- context "No view context registered" do
43
- it "is nil" do
44
- is_expected.to be_nil
45
- end
46
- end
47
-
48
- context "Default view context identifier" do
49
- context "View context registered in slice" do
50
- before do
51
- TestApp::App.register "views.context", slice_view_context
52
- end
53
-
54
- let(:slice_view_context) { double(:slice_view_context) }
55
-
56
- it "is the slice's view context" do
57
- is_expected.to eql slice_view_context
58
- end
59
- end
60
-
61
- context "View context registered in app" do
62
- before do
63
- Hanami.app.register "views.context", app_view_context
64
- end
65
-
66
- let(:app_view_context) { double(:app_view_context) }
67
-
68
- it "is the apps's view context" do
69
- is_expected.to eql app_view_context
70
- end
71
- end
72
- end
73
-
74
- context "custom view context identifier" do
75
- let(:app_hook) {
76
- proc do |app|
77
- app.config.actions.view_context_identifier = "view.custom_context"
78
- end
79
- }
80
-
81
- before do
82
- TestApp::App.register "view.custom_context", custom_view_context
83
- end
84
-
85
- let(:custom_view_context) { double(:custom_view_context) }
86
-
87
- it "is the context registered with the custom identifier" do
88
- is_expected.to eql custom_view_context
89
- end
90
- end
91
- end
92
-
93
- describe "#view_options" do
94
- subject(:view_options) { action.send(:view_options, req, res) }
95
- let(:req) { double(:req) }
96
- let(:res) { double(:res) }
97
-
98
- context "without view context" do
99
- it "is an empty hash" do
100
- is_expected.to eq({})
101
- end
102
- end
103
-
104
- context "with view context" do
105
- let(:initial_view_context) { double(:initial_view_context) }
106
- let(:action_args) { {view_context: initial_view_context} }
107
-
108
- context "default #view_context_options" do
109
- let(:request_view_context) { double(:request_view_context) }
110
-
111
- before do
112
- allow(initial_view_context).to receive(:with).with(
113
- request: req,
114
- response: res,
115
- ) { request_view_context }
116
- end
117
-
118
- it "is the view context with the request and response provided" do
119
- is_expected.to eq(context: request_view_context)
120
- end
121
- end
122
-
123
- context "custom #view_context_options" do
124
- let(:custom_view_context) { double(:custom_view_context)}
125
-
126
- before do
127
- action_class.class_eval do
128
- def view_context_options(req, res)
129
- {custom_option: "custom option"}
130
- end
131
- end
132
-
133
- allow(initial_view_context).to receive(:with).with(
134
- custom_option: "custom option"
135
- ) { custom_view_context }
136
- end
137
-
138
- it "is the view context with the custom options provided" do
139
- is_expected.to eq(context: custom_view_context)
140
- end
141
- end
142
-
143
- context "specialized method (calling super) defined in action class" do
144
- let(:request_view_context) { double(:request_view_context) }
145
-
146
- before do
147
- allow(initial_view_context).to receive(:with).with(
148
- request: req,
149
- response: res,
150
- ) { request_view_context }
151
-
152
- action_class.class_eval do
153
- def view_options(req, res)
154
- super.merge(extra_option: "extra option")
155
- end
156
- end
157
- end
158
-
159
- it "includes the options provided by the specialized method" do
160
- is_expected.to eq(context: request_view_context, extra_option: "extra option")
161
- end
162
- end
163
- end
164
- end
165
- end