hanami 2.0.0.beta1.1 → 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 +82 -0
- data/hanami.gemspec +1 -2
- data/lib/hanami/app.rb +76 -16
- data/lib/hanami/assets/{application_configuration.rb → app_configuration.rb} +1 -1
- data/lib/hanami/configuration/null_configuration.rb +2 -2
- data/lib/hanami/configuration.rb +36 -36
- data/lib/hanami/extensions/action/slice_configured_action.rb +44 -1
- data/lib/hanami/extensions/view/slice_configured_view.rb +47 -7
- data/lib/hanami/providers/rack.rb +2 -0
- data/lib/hanami/providers/settings.rb +81 -6
- data/lib/hanami/routes.rb +48 -21
- data/lib/hanami/settings/env_store.rb +32 -0
- data/lib/hanami/settings.rb +8 -12
- data/lib/hanami/setup.rb +1 -6
- data/lib/hanami/slice/routing/middleware/stack.rb +26 -5
- data/lib/hanami/slice.rb +38 -45
- data/lib/hanami/slice_configurable.rb +14 -1
- data/lib/hanami/slice_registrar.rb +65 -5
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami.rb +53 -2
- 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/integration/action/slice_configuration_spec.rb +287 -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/integration/code_loading/loading_from_lib_spec.rb +208 -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/integration/dotenv_loading_spec.rb +137 -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/integration/settings/access_to_constants_spec.rb +169 -0
- data/spec/integration/settings/loading_from_env_spec.rb +187 -0
- data/spec/integration/settings/settings_component_loading_spec.rb +113 -0
- data/spec/integration/settings/using_types_spec.rb +87 -0
- data/spec/integration/setup_spec.rb +165 -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/integration/slices/slice_loading_spec.rb +171 -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 +5 -1
- 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/integration/view/slice_configuration_spec.rb +289 -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 +4 -5
- 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/slices_spec.rb +34 -0
- data/spec/unit/hanami/configuration/views_spec.rb +4 -15
- data/spec/unit/hanami/settings/env_store_spec.rb +52 -0
- data/spec/unit/hanami/slice_configurable_spec.rb +2 -2
- data/spec/unit/hanami/version_spec.rb +1 -1
- metadata +105 -250
- data/lib/hanami/server.rb +0 -29
- data/lib/hanami/settings/dotenv_store.rb +0 -58
- 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/action/configuration_spec.rb +0 -26
- data/spec/new_integration/settings_spec.rb +0 -115
- data/spec/new_integration/view/configuration_spec.rb +0 -49
- 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
- data/spec/unit/hanami/settings/dotenv_store_spec.rb +0 -119
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hanami/routes"
|
4
|
-
|
5
|
-
RSpec.describe Hanami::Routes do
|
6
|
-
describe ".define" do
|
7
|
-
it "sets routes block" do
|
8
|
-
routes_class = Class.new(described_class)
|
9
|
-
|
10
|
-
routes_class.define { "Dummy routes" }
|
11
|
-
|
12
|
-
expect(routes_class.routes.call).to eq("Dummy routes")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe ".routes" do
|
17
|
-
context "when called before the routes have been defined" do
|
18
|
-
it "raises an error" do
|
19
|
-
routes_class = Class.new(described_class)
|
20
|
-
|
21
|
-
expect { routes_class.routes }.to raise_error(RuntimeError)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hanami/settings/dotenv_store"
|
4
|
-
require "dotenv"
|
5
|
-
|
6
|
-
RSpec.describe Hanami::Settings::DotenvStore do
|
7
|
-
def mock_dotenv(store)
|
8
|
-
dotenv = spy(:dotenv)
|
9
|
-
allow(store).to receive(:require).and_call_original
|
10
|
-
stub_const "Dotenv", dotenv
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#with_dotenv_loaded" do
|
14
|
-
context "dotenv available and environment other than test" do
|
15
|
-
it "requires and loads a range of dotenv files, specific to the current environment" do
|
16
|
-
store = described_class.new(store: {}, hanami_env: :development)
|
17
|
-
dotenv = mock_dotenv(store)
|
18
|
-
|
19
|
-
store.with_dotenv_loaded
|
20
|
-
|
21
|
-
expect(store).to have_received(:require).with("dotenv").ordered
|
22
|
-
expect(dotenv).to have_received(:load).ordered.with(
|
23
|
-
".env.development.local",
|
24
|
-
".env.local",
|
25
|
-
".env.development",
|
26
|
-
".env"
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns self" do
|
31
|
-
store = described_class.new(store: {}, hanami_env: :development)
|
32
|
-
|
33
|
-
expect(store.with_dotenv_loaded).to be(store)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "dotenv available and test environment" do
|
38
|
-
it "does not load .env.local (which is intended for non-test settings only)" do
|
39
|
-
store = described_class.new(store: {}, hanami_env: :test)
|
40
|
-
dotenv = mock_dotenv(store)
|
41
|
-
|
42
|
-
store.with_dotenv_loaded
|
43
|
-
|
44
|
-
expect(store).to have_received(:require).with("dotenv").ordered
|
45
|
-
expect(dotenv).to have_received(:load).ordered.with(
|
46
|
-
".env.test.local",
|
47
|
-
".env.test",
|
48
|
-
".env"
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "returns self" do
|
53
|
-
store = described_class.new(store: {}, hanami_env: :test)
|
54
|
-
|
55
|
-
expect(store.with_dotenv_loaded).to be(store)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "dotenv unavailable" do
|
60
|
-
let(:store) { described_class.new(store: {}) }
|
61
|
-
|
62
|
-
before do
|
63
|
-
allow(store).to receive(:require).with("dotenv").and_raise LoadError
|
64
|
-
end
|
65
|
-
|
66
|
-
it "attempts to require dotenv" do
|
67
|
-
store.with_dotenv_loaded
|
68
|
-
|
69
|
-
expect(store).to have_received(:require).with("dotenv")
|
70
|
-
end
|
71
|
-
|
72
|
-
it "gracefully ignores load errors" do
|
73
|
-
expect { store.with_dotenv_loaded }.not_to raise_error
|
74
|
-
end
|
75
|
-
|
76
|
-
it "returns self" do
|
77
|
-
expect(store.with_dotenv_loaded).to be(store)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "#fetch" do
|
83
|
-
it "fetches from ENV" do
|
84
|
-
store = described_class.new(store: { "FOO" => "bar" })
|
85
|
-
|
86
|
-
expect(store.fetch("FOO")).to eq("bar")
|
87
|
-
end
|
88
|
-
|
89
|
-
it "capitalizes name" do
|
90
|
-
store = described_class.new(store: { "FOO" => "bar" })
|
91
|
-
|
92
|
-
expect(store.fetch("foo")).to eq("bar")
|
93
|
-
end
|
94
|
-
|
95
|
-
it "coerces name to string" do
|
96
|
-
store = described_class.new(store: { "FOO" => "bar" })
|
97
|
-
|
98
|
-
expect(store.fetch(:foo)).to eq("bar")
|
99
|
-
end
|
100
|
-
|
101
|
-
it "returns default when value is not found" do
|
102
|
-
store = described_class.new(store: { "FOO" => "bar" })
|
103
|
-
|
104
|
-
expect(store.fetch("BAZ", "qux")).to eq("qux")
|
105
|
-
end
|
106
|
-
|
107
|
-
it "returns the block execution when value is not found" do
|
108
|
-
store = described_class.new(store: { "FOO" => "bar" })
|
109
|
-
|
110
|
-
expect(store.fetch("BAZ") { "qux" }).to eq("qux")
|
111
|
-
end
|
112
|
-
|
113
|
-
it "raises KeyError when value is not found and no default is given" do
|
114
|
-
store = described_class.new(store: { "FOO" => "bar" })
|
115
|
-
|
116
|
-
expect{ store.fetch("BAZ") }.to raise_error(KeyError)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|