hanami 2.0.2 → 2.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/LICENSE.md +1 -1
- data/README.md +25 -9
- data/hanami.gemspec +2 -2
- data/lib/hanami/config/actions.rb +0 -4
- data/lib/hanami/config/logger.rb +1 -1
- data/lib/hanami/config/views.rb +0 -4
- data/lib/hanami/config.rb +54 -0
- data/lib/hanami/extensions/action/slice_configured_action.rb +15 -7
- data/lib/hanami/extensions/action.rb +4 -4
- data/lib/hanami/extensions/router/errors.rb +58 -0
- data/lib/hanami/extensions/view/context.rb +129 -60
- data/lib/hanami/extensions/view/part.rb +26 -0
- data/lib/hanami/extensions/view/scope.rb +26 -0
- data/lib/hanami/extensions/view/slice_configured_context.rb +0 -2
- data/lib/hanami/extensions/view/slice_configured_helpers.rb +44 -0
- data/lib/hanami/extensions/view/slice_configured_view.rb +106 -21
- data/lib/hanami/extensions/view/standard_helpers.rb +14 -0
- data/lib/hanami/extensions.rb +10 -3
- data/lib/hanami/helpers/form_helper/form_builder.rb +1391 -0
- data/lib/hanami/helpers/form_helper/values.rb +75 -0
- data/lib/hanami/helpers/form_helper.rb +213 -0
- data/lib/hanami/middleware/public_errors_app.rb +75 -0
- data/lib/hanami/middleware/render_errors.rb +93 -0
- data/lib/hanami/slice.rb +28 -2
- data/lib/hanami/slice_configurable.rb +3 -2
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami/web/rack_logger.rb +8 -20
- data/lib/hanami.rb +1 -1
- data/spec/integration/action/view_rendering/view_context_spec.rb +221 -0
- data/spec/integration/action/view_rendering_spec.rb +0 -18
- data/spec/integration/rack_app/middleware_spec.rb +23 -23
- data/spec/integration/rack_app/rack_app_spec.rb +5 -1
- data/spec/integration/slices/slice_registrations_spec.rb +80 -0
- data/spec/integration/view/config/default_context_spec.rb +149 -0
- data/spec/integration/view/{inflector_spec.rb → config/inflector_spec.rb} +1 -1
- data/spec/integration/view/config/part_class_spec.rb +147 -0
- data/spec/integration/view/config/part_namespace_spec.rb +103 -0
- data/spec/integration/view/config/paths_spec.rb +119 -0
- data/spec/integration/view/config/scope_class_spec.rb +147 -0
- data/spec/integration/view/config/scope_namespace_spec.rb +103 -0
- data/spec/integration/view/config/template_spec.rb +38 -0
- data/spec/integration/view/context/request_spec.rb +3 -7
- data/spec/integration/view/helpers/form_helper_spec.rb +174 -0
- data/spec/integration/view/helpers/part_helpers_spec.rb +124 -0
- data/spec/integration/view/helpers/scope_helpers_spec.rb +84 -0
- data/spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb +162 -0
- data/spec/integration/view/helpers/user_defined_helpers/scope_helpers_spec.rb +119 -0
- data/spec/integration/view/slice_configuration_spec.rb +9 -9
- data/spec/integration/web/render_detailed_errors_spec.rb +90 -0
- data/spec/integration/web/render_errors_spec.rb +240 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/matchers.rb +32 -0
- data/spec/unit/hanami/config/actions/default_values_spec.rb +0 -4
- data/spec/unit/hanami/config/logger_spec.rb +9 -0
- data/spec/unit/hanami/config/render_detailed_errors_spec.rb +25 -0
- data/spec/unit/hanami/config/render_errors_spec.rb +25 -0
- data/spec/unit/hanami/config/views_spec.rb +0 -18
- data/spec/unit/hanami/extensions/view/context_spec.rb +59 -0
- data/spec/unit/hanami/helpers/form_helper_spec.rb +2826 -0
- data/spec/unit/hanami/router/errors/not_allowed_error_spec.rb +27 -0
- data/spec/unit/hanami/router/errors/not_found_error_spec.rb +22 -0
- data/spec/unit/hanami/slice_configurable_spec.rb +18 -0
- data/spec/unit/hanami/version_spec.rb +1 -1
- data/spec/unit/hanami/web/rack_logger_spec.rb +1 -1
- metadata +67 -33
- data/spec/integration/action/view_integration_spec.rb +0 -165
- data/spec/integration/view/part_namespace_spec.rb +0 -96
- data/spec/integration/view/path_spec.rb +0 -56
- data/spec/integration/view/template_spec.rb +0 -68
- data/spec/isolation/hanami/application/already_configured_spec.rb +0 -19
- data/spec/isolation/hanami/application/inherit_anonymous_class_spec.rb +0 -10
- data/spec/isolation/hanami/application/inherit_concrete_class_spec.rb +0 -14
- data/spec/isolation/hanami/application/not_configured_spec.rb +0 -9
- data/spec/isolation/hanami/application/routes/configured_spec.rb +0 -44
- data/spec/isolation/hanami/application/routes/not_configured_spec.rb +0 -16
- data/spec/isolation/hanami/boot/success_spec.rb +0 -50
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hanami"
|
4
|
-
|
5
|
-
RSpec.describe "App view / Template", :app_integration do
|
6
|
-
before do
|
7
|
-
module TestApp
|
8
|
-
class App < Hanami::App
|
9
|
-
config.root = "/test_app"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
Hanami.app.instance_eval(&app_hook) if respond_to?(:app_hook)
|
14
|
-
Hanami.app.register_slice :main
|
15
|
-
Hanami.app.prepare
|
16
|
-
|
17
|
-
module TestApp
|
18
|
-
class View < Hanami::View
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
subject(:template) { view_class.config.template }
|
24
|
-
|
25
|
-
context "Ordinary app view" do
|
26
|
-
before do
|
27
|
-
module TestApp
|
28
|
-
module Views
|
29
|
-
module Article
|
30
|
-
class Index < TestApp::View
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
let(:view_class) { TestApp::Views::Article::Index }
|
38
|
-
|
39
|
-
it "configures the tempalte to match the class name" do
|
40
|
-
expect(template).to eq "article/index"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "Slice view with namespace matching template inference base" do
|
45
|
-
before do
|
46
|
-
module TestApp
|
47
|
-
module MyViews
|
48
|
-
module Users
|
49
|
-
class Show < TestApp::View
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
let(:app_hook) {
|
57
|
-
proc do
|
58
|
-
config.views.template_inference_base = "my_views"
|
59
|
-
end
|
60
|
-
}
|
61
|
-
|
62
|
-
let(:view_class) { TestApp::MyViews::Users::Show }
|
63
|
-
|
64
|
-
it "configures the tempalte to match the class name" do
|
65
|
-
expect(template).to eq "users/show"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bookshelf
|
4
|
-
class App < Hanami::App
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
RSpec.describe Hanami do
|
9
|
-
describe ".application" do
|
10
|
-
it "it raises error when already assigned" do
|
11
|
-
expect do
|
12
|
-
module Soundcard
|
13
|
-
class App < Hanami::App
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end.to raise_error("Hanami.app already configured")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Hanami do
|
4
|
-
describe ".application" do
|
5
|
-
it "it doesn't assign when anonymous class inherits Hanami::Application" do
|
6
|
-
Class.new(Hanami::Application)
|
7
|
-
expect { Hanami.app }.to raise_error("Hanami.app not configured")
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bookshelf
|
4
|
-
class App < Hanami::App
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
RSpec.describe Hanami do
|
9
|
-
describe ".application" do
|
10
|
-
it "it assign when concrete class inherits Hanami::Application" do
|
11
|
-
expect(Hanami.app).to eq(Bookshelf::Application)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hanami/action"
|
4
|
-
|
5
|
-
module Bookshelf
|
6
|
-
class App < Hanami::App
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module Web
|
11
|
-
end
|
12
|
-
Hanami.app.register_slice :web, namespace: Web
|
13
|
-
|
14
|
-
Hanami.prepare
|
15
|
-
|
16
|
-
module Web
|
17
|
-
class Action < Hanami::Action
|
18
|
-
end
|
19
|
-
|
20
|
-
module Actions
|
21
|
-
module Home
|
22
|
-
class Index < Web::Action
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
Hanami.app.routes do
|
29
|
-
mount :web, at: "/" do
|
30
|
-
root to: "home#index"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec.describe Hanami::Application do
|
35
|
-
describe ".routes" do
|
36
|
-
subject { Hanami.app.routes }
|
37
|
-
|
38
|
-
it "returns configured routes" do
|
39
|
-
expect(subject).to be_kind_of(Proc)
|
40
|
-
# FIXME: make this expectation to pass
|
41
|
-
# expect(subject.for(:web).url(:root)).to eq("/")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bookshelf
|
4
|
-
class App < Hanami::App
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
RSpec.describe Hanami::Application do
|
9
|
-
describe ".routes" do
|
10
|
-
subject { Hanami.app.routes }
|
11
|
-
|
12
|
-
it "raises error when not configured" do
|
13
|
-
expect { subject }.to raise_error("Hanami.app.routes not configured")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hanami/action"
|
4
|
-
require "hanami/logger"
|
5
|
-
|
6
|
-
module Bookshelf
|
7
|
-
class App < Hanami::App
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
module Web
|
12
|
-
end
|
13
|
-
slice = Hanami.app.register_slice :web, namespace: Web
|
14
|
-
|
15
|
-
Hanami.prepare
|
16
|
-
|
17
|
-
Hanami.app.routes do
|
18
|
-
mount :web, at: "/" do
|
19
|
-
root to: "home#index"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
module Web
|
24
|
-
class Action < Hanami::Action
|
25
|
-
end
|
26
|
-
|
27
|
-
module Actions
|
28
|
-
module Home
|
29
|
-
class Index < Web::Action
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
slice.register "actions.home.index" do
|
36
|
-
Web::Actions::Home::Index.new
|
37
|
-
end
|
38
|
-
|
39
|
-
RSpec.describe Hanami do
|
40
|
-
describe ".boot" do
|
41
|
-
it "assigns Hanami.app, .root, and .logger" do
|
42
|
-
pending "Failing due to dry-system changes"
|
43
|
-
|
44
|
-
Hanami.boot
|
45
|
-
expect(Hanami.app.ancestors).to include(Hanami::Application)
|
46
|
-
expect(Hanami.app.root).to eq(Dir.pwd)
|
47
|
-
expect(Hanami.logger).to be_kind_of(Dry::Logger::Dispatcher)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|