hanami 2.0.0.beta2 → 2.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -1
- data/hanami.gemspec +5 -5
- data/lib/hanami/app.rb +4 -4
- data/lib/hanami/assets/{app_configuration.rb → app_config.rb} +10 -10
- data/lib/hanami/assets/{configuration.rb → config.rb} +4 -4
- data/lib/hanami/{configuration → config}/actions/content_security_policy.rb +2 -2
- data/lib/hanami/{configuration → config}/actions/cookies.rb +6 -5
- data/lib/hanami/{configuration → config}/actions/sessions.rb +2 -2
- data/lib/hanami/{configuration → config}/actions.rb +11 -12
- data/lib/hanami/{configuration → config}/logger.rb +2 -2
- data/lib/hanami/config/null_config.rb +14 -0
- data/lib/hanami/{configuration → config}/router.rb +8 -8
- data/lib/hanami/{configuration → config}/sessions.rb +2 -2
- data/lib/hanami/{configuration → config}/views.rb +10 -10
- data/lib/hanami/{configuration.rb → config.rb} +30 -30
- data/lib/hanami/errors.rb +3 -0
- data/lib/hanami/extensions/action/slice_configured_action.rb +1 -1
- data/lib/hanami/providers/inflector.rb +0 -2
- data/lib/hanami/providers/logger.rb +1 -3
- data/lib/hanami/providers/rack.rb +0 -2
- data/lib/hanami/providers/routes.rb +0 -2
- data/lib/hanami/routes.rb +48 -21
- data/lib/hanami/settings/env_store.rb +3 -3
- data/lib/hanami/settings.rb +87 -5
- data/lib/hanami/slice/routing/middleware/stack.rb +45 -1
- data/lib/hanami/slice.rb +52 -37
- data/lib/hanami/slice_configurable.rb +1 -1
- data/lib/hanami/slice_registrar.rb +6 -0
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami.rb +0 -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 +2 -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/integration/rack_app/body_parser_spec.rb +108 -0
- data/spec/{new_integration → integration}/rack_app/middleware_spec.rb +37 -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/integration/settings/access_in_slice_class_body_spec.rb +82 -0
- data/spec/integration/settings/access_to_constants_spec.rb +46 -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/slices/slice_settings_spec.rb → integration/settings/slice_registration_spec.rb} +5 -1
- data/spec/{new_integration → integration}/settings/using_types_spec.rb +4 -11
- 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_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/support/app_integration.rb +18 -15
- data/spec/unit/hanami/{configuration → config}/actions/content_security_policy_spec.rb +10 -10
- data/spec/unit/hanami/{configuration → config}/actions/cookies_spec.rb +6 -6
- data/spec/unit/hanami/{configuration → config}/actions/csrf_protection_spec.rb +12 -12
- data/spec/unit/hanami/config/actions/default_values_spec.rb +54 -0
- data/spec/unit/hanami/{configuration → config}/actions/sessions_spec.rb +5 -5
- data/spec/unit/hanami/{configuration → config}/actions_spec.rb +13 -25
- data/spec/unit/hanami/{configuration → config}/base_url_spec.rb +2 -2
- data/spec/unit/hanami/{configuration → config}/inflector_spec.rb +2 -2
- data/spec/unit/hanami/{configuration → config}/logger_spec.rb +4 -4
- data/spec/unit/hanami/config/router_spec.rb +44 -0
- data/spec/unit/hanami/{configuration → config}/slices_spec.rb +2 -2
- data/spec/unit/hanami/{configuration → config}/views_spec.rb +15 -27
- data/spec/unit/hanami/{configuration_spec.rb → config_spec.rb} +3 -3
- data/spec/unit/hanami/settings_spec.rb +65 -10
- data/spec/unit/hanami/slice_configurable_spec.rb +21 -2
- data/spec/unit/hanami/version_spec.rb +1 -1
- metadata +162 -294
- data/lib/hanami/configuration/null_configuration.rb +0 -14
- data/lib/hanami/providers/settings.rb +0 -98
- 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/new_integration/settings/access_to_constants_spec.rb +0 -169
- 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/configuration/actions/default_values_spec.rb +0 -52
- data/spec/unit/hanami/routes_spec.rb +0 -25
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -23,6 +23,23 @@ RSpec.shared_context "Application integration" do
|
|
23
23
|
let(:app_modules) { %i[TestApp Admin Main Search] }
|
24
24
|
end
|
25
25
|
|
26
|
+
def autoloaders_teardown!
|
27
|
+
# Tear down Zeitwerk (from zeitwerk's own test/support/loader_test)
|
28
|
+
Zeitwerk::Registry.loaders.reject! do |loader|
|
29
|
+
test_loader = loader.dirs.any? { |dir|
|
30
|
+
dir.include?("/spec/") || dir.include?(Dir.tmpdir) ||
|
31
|
+
dir.include?("/slices/") || dir.include?("/app")
|
32
|
+
}
|
33
|
+
|
34
|
+
if test_loader
|
35
|
+
loader.unregister
|
36
|
+
true
|
37
|
+
else
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
26
43
|
RSpec.configure do |config|
|
27
44
|
config.include RSpec::Support::Files, :app_integration
|
28
45
|
config.include RSpec::Support::WithTmpDirectory, :app_integration
|
@@ -36,21 +53,7 @@ RSpec.configure do |config|
|
|
36
53
|
end
|
37
54
|
|
38
55
|
config.after :each, :app_integration do
|
39
|
-
|
40
|
-
Zeitwerk::Registry.loaders.each(&:unload)
|
41
|
-
Zeitwerk::Registry.loaders.clear
|
42
|
-
|
43
|
-
# This private interface changes between 2.5.4 and 2.6.0
|
44
|
-
if Zeitwerk::Registry.respond_to?(:loaders_managing_gems)
|
45
|
-
Zeitwerk::Registry.loaders_managing_gems.clear
|
46
|
-
else
|
47
|
-
Zeitwerk::Registry.gem_loaders_by_root_file.clear
|
48
|
-
Zeitwerk::Registry.autoloads.clear
|
49
|
-
Zeitwerk::Registry.inceptions.clear
|
50
|
-
end
|
51
|
-
|
52
|
-
Zeitwerk::ExplicitNamespace.cpaths.clear
|
53
|
-
Zeitwerk::ExplicitNamespace.tracer.disable
|
56
|
+
autoloaders_teardown!
|
54
57
|
|
55
58
|
Hanami.instance_variable_set(:@_bundled, {})
|
56
59
|
Hanami.remove_instance_variable(:@_app) if Hanami.instance_variable_defined?(:@_app)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
3
|
+
require "hanami/config/actions"
|
4
4
|
|
5
|
-
RSpec.describe Hanami::
|
6
|
-
let(:
|
7
|
-
subject(:content_security_policy) {
|
5
|
+
RSpec.describe Hanami::Config::Actions, "#content_security_policy" do
|
6
|
+
let(:config) { described_class.new }
|
7
|
+
subject(:content_security_policy) { config.content_security_policy }
|
8
8
|
|
9
9
|
context "no CSP config specified" do
|
10
10
|
context "without assets_server_url" do
|
@@ -34,7 +34,7 @@ RSpec.describe Hanami::Configuration::Actions, "#content_security_policy" do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
context "with assets_server_url" do
|
37
|
-
let(:
|
37
|
+
let(:config) { described_class.new(assets_server_url: assets_server_url) }
|
38
38
|
let(:assets_server_url) { "http://localhost:8080" }
|
39
39
|
|
40
40
|
it "includes server url" do
|
@@ -85,18 +85,18 @@ RSpec.describe Hanami::Configuration::Actions, "#content_security_policy" do
|
|
85
85
|
|
86
86
|
context "with CSP enabled" do
|
87
87
|
it "sets default header" do
|
88
|
-
|
88
|
+
config.finalize!
|
89
89
|
|
90
|
-
expect(
|
90
|
+
expect(config.default_headers.fetch("Content-Security-Policy")).to eq(content_security_policy.to_str)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
context "with CSP disabled" do
|
95
95
|
it "doesn't set default header" do
|
96
|
-
|
97
|
-
|
96
|
+
config.content_security_policy = false
|
97
|
+
config.finalize!
|
98
98
|
|
99
|
-
expect(
|
99
|
+
expect(config.default_headers.key?("Content-Security-Policy")).to be(false)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
3
|
+
require "hanami/config/actions"
|
4
4
|
|
5
|
-
RSpec.describe Hanami::
|
6
|
-
let(:
|
7
|
-
subject(:cookies) {
|
5
|
+
RSpec.describe Hanami::Config::Actions, "#cookies" do
|
6
|
+
let(:config) { described_class.new }
|
7
|
+
subject(:cookies) { config.cookies }
|
8
8
|
|
9
9
|
context "default config" do
|
10
10
|
it "is enabled" do
|
@@ -18,7 +18,7 @@ RSpec.describe Hanami::Configuration::Actions, "#cookies" do
|
|
18
18
|
|
19
19
|
context "options given" do
|
20
20
|
before do
|
21
|
-
|
21
|
+
config.cookies = {max_age: 300}
|
22
22
|
end
|
23
23
|
|
24
24
|
it "is enabled" do
|
@@ -32,7 +32,7 @@ RSpec.describe Hanami::Configuration::Actions, "#cookies" do
|
|
32
32
|
|
33
33
|
context "nil value given" do
|
34
34
|
before do
|
35
|
-
|
35
|
+
config.cookies = nil
|
36
36
|
end
|
37
37
|
|
38
38
|
it "is not enabled" do
|
@@ -1,32 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
3
|
+
require "hanami/config/actions"
|
4
4
|
|
5
|
-
RSpec.describe Hanami::
|
6
|
-
let(:
|
7
|
-
subject(:value) {
|
5
|
+
RSpec.describe Hanami::Config::Actions, "#csrf_protection" do
|
6
|
+
let(:config) { described_class.new }
|
7
|
+
subject(:value) { config.csrf_protection }
|
8
8
|
|
9
|
-
context "non-finalized
|
9
|
+
context "non-finalized config" do
|
10
10
|
it "returns a default of nil" do
|
11
11
|
is_expected.to be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
it "can be explicitly enabled" do
|
15
|
-
|
15
|
+
config.csrf_protection = true
|
16
16
|
is_expected.to be true
|
17
17
|
end
|
18
18
|
|
19
19
|
it "can be explicitly disabled" do
|
20
|
-
|
20
|
+
config.csrf_protection = false
|
21
21
|
is_expected.to be false
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
context "finalized
|
25
|
+
context "finalized config" do
|
26
26
|
context "sessions enabled" do
|
27
27
|
before do
|
28
|
-
|
29
|
-
|
28
|
+
config.sessions = :cookie, {secret: "abc"}
|
29
|
+
config.finalize!
|
30
30
|
end
|
31
31
|
|
32
32
|
it "is true" do
|
@@ -35,7 +35,7 @@ RSpec.describe Hanami::Configuration::Actions, "#csrf_protection" do
|
|
35
35
|
|
36
36
|
context "explicitly disabled" do
|
37
37
|
before do
|
38
|
-
|
38
|
+
config.csrf_protection = false
|
39
39
|
end
|
40
40
|
|
41
41
|
it "is false" do
|
@@ -46,7 +46,7 @@ RSpec.describe Hanami::Configuration::Actions, "#csrf_protection" do
|
|
46
46
|
|
47
47
|
context "sessions not enabled" do
|
48
48
|
before do
|
49
|
-
|
49
|
+
config.finalize!
|
50
50
|
end
|
51
51
|
|
52
52
|
it "is true" do
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hanami/config/actions"
|
4
|
+
|
5
|
+
RSpec.describe Hanami::Config::Actions, "default values" do
|
6
|
+
subject(:config) { described_class.new }
|
7
|
+
|
8
|
+
describe "sessions" do
|
9
|
+
specify { expect(config.sessions).not_to be_enabled }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "name_inference_base" do
|
13
|
+
specify { expect(config.name_inference_base).to eq "actions" }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "view_context_identifier" do
|
17
|
+
specify { expect(config.view_context_identifier).to eq "views.context" }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "view_name_inferrer" do
|
21
|
+
specify { expect(config.view_name_inferrer).to eq Hanami::Slice::ViewNameInferrer }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "view_name_inference_base" do
|
25
|
+
specify { expect(config.view_name_inference_base).to eq "views" }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "new default values applied to base action settings" do
|
29
|
+
describe "default_request_format" do
|
30
|
+
specify { expect(config.default_request_format).to eq :html }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "default_response_format" do
|
34
|
+
specify { expect(config.default_response_format).to eq :html }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "content_security_policy" do
|
38
|
+
specify { expect(config.content_security_policy).to be_kind_of(Hanami::Config::Actions::ContentSecurityPolicy) }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "default_headers" do
|
42
|
+
specify {
|
43
|
+
config.finalize!
|
44
|
+
|
45
|
+
expect(config.default_headers).to eq(
|
46
|
+
"X-Frame-Options" => "DENY",
|
47
|
+
"X-Content-Type-Options" => "nosniff",
|
48
|
+
"X-XSS-Protection" => "1; mode=block",
|
49
|
+
"Content-Security-Policy" => config.content_security_policy.to_str
|
50
|
+
)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
3
|
+
require "hanami/config/actions"
|
4
4
|
|
5
|
-
RSpec.describe Hanami::
|
6
|
-
let(:
|
7
|
-
subject(:sessions) {
|
5
|
+
RSpec.describe Hanami::Config::Actions, "#sessions" do
|
6
|
+
let(:config) { described_class.new }
|
7
|
+
subject(:sessions) { config.sessions }
|
8
8
|
|
9
9
|
context "no session config specified" do
|
10
10
|
it "is not enabled" do
|
@@ -26,7 +26,7 @@ RSpec.describe Hanami::Configuration::Actions, "#sessions" do
|
|
26
26
|
|
27
27
|
context "valid session config provided" do
|
28
28
|
before do
|
29
|
-
|
29
|
+
config.sessions = :cookie, {secret: "abc"}
|
30
30
|
end
|
31
31
|
|
32
32
|
it "is enabled" do
|
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
4
|
-
require "hanami/
|
5
|
-
require "hanami/action/configuration"
|
3
|
+
require "hanami/config"
|
4
|
+
require "hanami/action"
|
6
5
|
|
7
|
-
RSpec.describe Hanami::
|
8
|
-
let(:
|
6
|
+
RSpec.describe Hanami::Config, "#actions" do
|
7
|
+
let(:config) { described_class.new(app_name: app_name, env: :development) }
|
9
8
|
let(:app_name) { "MyApp::app" }
|
10
9
|
|
11
|
-
subject(:actions) {
|
10
|
+
subject(:actions) { config.actions }
|
12
11
|
|
13
|
-
context "
|
14
|
-
it "is a full actions
|
15
|
-
is_expected.to be_an_instance_of(Hanami::
|
12
|
+
context "hanami-controller is bundled" do
|
13
|
+
it "is a full actions config" do
|
14
|
+
is_expected.to be_an_instance_of(Hanami::Config::Actions)
|
16
15
|
|
17
16
|
is_expected.to respond_to(:default_response_format)
|
18
17
|
is_expected.to respond_to(:default_response_format=)
|
@@ -43,30 +42,19 @@ RSpec.describe Hanami::Configuration, "#actions" do
|
|
43
42
|
end
|
44
43
|
|
45
44
|
it "includes all base action settings" do
|
46
|
-
expect(actions.settings).to include(Hanami::Action
|
45
|
+
expect(actions.settings).to include(Hanami::Action.settings)
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
context "
|
50
|
+
context "hanami-controller is not bundled" do
|
52
51
|
before do
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
allow_any_instance_of(described_class)
|
58
|
-
.to receive(:require)
|
59
|
-
.with(anything)
|
60
|
-
.and_call_original
|
61
|
-
|
62
|
-
allow_any_instance_of(described_class)
|
63
|
-
.to receive(:require)
|
64
|
-
.with("hanami/action")
|
65
|
-
.and_raise load_error
|
52
|
+
allow(Hanami).to receive(:bundled?).and_call_original
|
53
|
+
expect(Hanami).to receive(:bundled?).with("hanami-controller").and_return(false)
|
66
54
|
end
|
67
55
|
|
68
56
|
it "does not expose any settings" do
|
69
|
-
is_expected.not_to be_an_instance_of(Hanami::
|
57
|
+
is_expected.not_to be_an_instance_of(Hanami::Config::Actions)
|
70
58
|
is_expected.not_to respond_to(:default_response_format)
|
71
59
|
is_expected.not_to respond_to(:default_response_format=)
|
72
60
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
3
|
+
require "hanami/config"
|
4
4
|
require "uri"
|
5
5
|
|
6
|
-
RSpec.describe Hanami::
|
6
|
+
RSpec.describe Hanami::Config, "base_url" do
|
7
7
|
subject(:config) { described_class.new(app_name: app_name, env: :development) }
|
8
8
|
let(:app_name) { "MyApp::app" }
|
9
9
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
3
|
+
require "hanami/config"
|
4
4
|
|
5
|
-
RSpec.describe Hanami::
|
5
|
+
RSpec.describe Hanami::Config do
|
6
6
|
subject(:config) { described_class.new(app_name: app_name, env: :development) }
|
7
7
|
let(:app_name) { "MyApp::app" }
|
8
8
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
3
|
+
require "hanami/config/logger"
|
4
4
|
require "hanami/slice_name"
|
5
5
|
require "dry/inflector"
|
6
6
|
require "logger"
|
7
7
|
|
8
|
-
RSpec.describe Hanami::
|
8
|
+
RSpec.describe Hanami::Config::Logger do
|
9
9
|
subject { described_class.new(app_name: app_name, env: env) }
|
10
10
|
let(:app_name) { Hanami::SliceName.new(double(name: "MyApp::app"), inflector: -> { Dry::Inflector.new }) }
|
11
11
|
let(:env) { :development }
|
@@ -165,7 +165,7 @@ RSpec.describe Hanami::Configuration::Logger do
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
-
RSpec.describe Hanami::
|
168
|
+
RSpec.describe Hanami::Config do
|
169
169
|
subject(:config) { described_class.new(app_name: app_name, env: env) }
|
170
170
|
let(:app_name) { Hanami::SliceName.new(double(name: "SOS::app"), inflector: -> { Dry::Inflector.new }) }
|
171
171
|
let(:env) { :development }
|
@@ -180,7 +180,7 @@ RSpec.describe Hanami::Configuration do
|
|
180
180
|
end
|
181
181
|
|
182
182
|
describe "#app_name" do
|
183
|
-
it "defaults to Hanami::
|
183
|
+
it "defaults to Hanami::Config#app_name" do
|
184
184
|
expect(config.logger.app_name).to eq(config.app_name)
|
185
185
|
end
|
186
186
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hanami/config"
|
4
|
+
|
5
|
+
RSpec.describe Hanami::Config, "#router" do
|
6
|
+
let(:config) { described_class.new(app_name: app_name, env: :development) }
|
7
|
+
let(:app_name) { "MyApp::app" }
|
8
|
+
|
9
|
+
subject(:router) { config.router }
|
10
|
+
|
11
|
+
context "hanami-router is bundled" do
|
12
|
+
it "is a full router configuration" do
|
13
|
+
is_expected.to be_an_instance_of(Hanami::Config::Router)
|
14
|
+
|
15
|
+
is_expected.to respond_to(:resolver)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "loads the middleware stack" do
|
19
|
+
subject
|
20
|
+
|
21
|
+
expect(config.middleware_stack).not_to be_nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can be finalized" do
|
25
|
+
is_expected.to respond_to(:finalize!)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "hanami-router is not bundled" do
|
30
|
+
before do
|
31
|
+
allow(Hanami).to receive(:bundled?).and_call_original
|
32
|
+
expect(Hanami).to receive(:bundled?).with("hanami-router").and_return(false)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does not expose any settings" do
|
36
|
+
is_expected.not_to be_an_instance_of(Hanami::Config::Router)
|
37
|
+
is_expected.not_to respond_to(:resolver)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "can be finalized" do
|
41
|
+
is_expected.to respond_to(:finalize!)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "dry/inflector"
|
4
|
-
require "hanami/
|
4
|
+
require "hanami/config"
|
5
5
|
require "hanami/slice_name"
|
6
6
|
|
7
|
-
RSpec.describe Hanami::
|
7
|
+
RSpec.describe Hanami::Config, "#slices" do
|
8
8
|
subject(:config) { described_class.new(app_name: app_name, env: :development) }
|
9
9
|
let(:app_name) { Hanami::SliceName.new(double(name: "MyApp::App"), inflector: Dry::Inflector.new) }
|
10
10
|
|
@@ -1,25 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/
|
4
|
-
require "hanami/configuration/views"
|
3
|
+
require "hanami/config"
|
5
4
|
require "saharspec/matchers/dont"
|
6
5
|
|
7
|
-
RSpec.describe Hanami::
|
8
|
-
let(:
|
6
|
+
RSpec.describe Hanami::Config, "#views" do
|
7
|
+
let(:config) { described_class.new(app_name: app_name, env: :development) }
|
9
8
|
let(:app_name) { "MyApp::app" }
|
10
9
|
|
11
|
-
subject(:views) {
|
10
|
+
subject(:views) { config.views }
|
12
11
|
|
13
|
-
context "
|
14
|
-
it "exposes Hanami::Views's app
|
15
|
-
is_expected.to be_an_instance_of(Hanami::
|
12
|
+
context "hanami-view is bundled" do
|
13
|
+
it "exposes Hanami::Views's app config" do
|
14
|
+
is_expected.to be_an_instance_of(Hanami::Config::Views)
|
16
15
|
|
17
16
|
is_expected.to respond_to(:finalize!)
|
18
17
|
is_expected.to respond_to(:layouts_dir)
|
19
18
|
is_expected.to respond_to(:layouts_dir=)
|
20
19
|
end
|
21
20
|
|
22
|
-
it "includes base view
|
21
|
+
it "includes base view config" do
|
23
22
|
expect(views).to respond_to(:paths)
|
24
23
|
expect(views).to respond_to(:paths=)
|
25
24
|
end
|
@@ -39,11 +38,11 @@ RSpec.describe Hanami::Configuration, "#views" do
|
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
42
|
-
it "preserves default values from the base view
|
41
|
+
it "preserves default values from the base view config" do
|
43
42
|
expect(views.layouts_dir).to eq Hanami::View.config.layouts_dir
|
44
43
|
end
|
45
44
|
|
46
|
-
it "allows settings to be configured independently of the base view
|
45
|
+
it "allows settings to be configured independently of the base view config" do
|
47
46
|
expect { views.layouts_dir = "custom_layouts" }
|
48
47
|
.to change { views.layouts_dir }.to("custom_layouts")
|
49
48
|
.and(dont.change { Hanami::View.config.layouts_dir })
|
@@ -71,7 +70,7 @@ RSpec.describe Hanami::Configuration, "#views" do
|
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
74
|
-
describe "finalized
|
73
|
+
describe "finalized config" do
|
75
74
|
before do
|
76
75
|
views.finalize!
|
77
76
|
end
|
@@ -90,25 +89,14 @@ RSpec.describe Hanami::Configuration, "#views" do
|
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
93
|
-
context "
|
92
|
+
context "hanami-view is not bundled" do
|
94
93
|
before do
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
allow_any_instance_of(described_class)
|
100
|
-
.to receive(:require)
|
101
|
-
.with(anything)
|
102
|
-
.and_call_original
|
103
|
-
|
104
|
-
allow_any_instance_of(described_class)
|
105
|
-
.to receive(:require)
|
106
|
-
.with("hanami/view")
|
107
|
-
.and_raise load_error
|
94
|
+
allow(Hanami).to receive(:bundled?).and_call_original
|
95
|
+
expect(Hanami).to receive(:bundled?).with("hanami-view").and_return(false)
|
108
96
|
end
|
109
97
|
|
110
98
|
it "does not expose any settings" do
|
111
|
-
is_expected.not_to be_an_instance_of(Hanami::
|
99
|
+
is_expected.not_to be_an_instance_of(Hanami::Config::Views)
|
112
100
|
is_expected.not_to respond_to(:layouts_dir)
|
113
101
|
is_expected.not_to respond_to(:layouts_dir=)
|
114
102
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require "hanami/
|
1
|
+
require "hanami/config"
|
2
2
|
|
3
|
-
RSpec.describe Hanami::
|
3
|
+
RSpec.describe Hanami::Config do
|
4
4
|
let(:config) { described_class.new(app_name: app_name, env: env) }
|
5
5
|
let(:app_name) { "MyApp::app" }
|
6
6
|
let(:env) { :development }
|
7
7
|
|
8
|
-
describe "environment-specific
|
8
|
+
describe "environment-specific config" do
|
9
9
|
before do
|
10
10
|
config.logger.level = :debug__set_without_env
|
11
11
|
end
|