hanami 2.1.0.beta2.1 → 2.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/hanami.gemspec +1 -1
  4. data/lib/hanami/config/actions.rb +14 -0
  5. data/lib/hanami/extensions/action/slice_configured_action.rb +5 -5
  6. data/lib/hanami/extensions/action.rb +4 -4
  7. data/lib/hanami/extensions/view/context.rb +0 -11
  8. data/lib/hanami/extensions/view/part.rb +51 -2
  9. data/lib/hanami/extensions/view/slice_configured_part.rb +72 -0
  10. data/lib/hanami/extensions/view/slice_configured_view.rb +2 -2
  11. data/lib/hanami/helpers/assets_helper.rb +6 -38
  12. data/lib/hanami/routes.rb +33 -2
  13. data/lib/hanami/slice.rb +12 -2
  14. data/lib/hanami/slice_registrar.rb +48 -23
  15. data/lib/hanami/version.rb +1 -1
  16. data/lib/hanami/web/rack_logger.rb +70 -2
  17. data/lib/hanami/web/welcome.html.erb +203 -0
  18. data/lib/hanami/web/welcome.rb +46 -0
  19. data/spec/integration/assets/assets_spec.rb +14 -3
  20. data/spec/integration/logging/request_logging_spec.rb +65 -7
  21. data/spec/integration/rack_app/method_override_spec.rb +97 -0
  22. data/spec/integration/slices_spec.rb +275 -5
  23. data/spec/integration/view/context/assets_spec.rb +0 -8
  24. data/spec/integration/view/context/inflector_spec.rb +0 -8
  25. data/spec/integration/view/context/settings_spec.rb +0 -8
  26. data/spec/integration/view/helpers/part_helpers_spec.rb +2 -2
  27. data/spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb +10 -10
  28. data/spec/integration/view/parts/default_rendering_spec.rb +138 -0
  29. data/spec/integration/web/welcome_view_spec.rb +84 -0
  30. data/spec/support/app_integration.rb +22 -4
  31. data/spec/unit/hanami/helpers/assets_helper/{audio_spec.rb → audio_tag_spec.rb} +10 -14
  32. data/spec/unit/hanami/helpers/assets_helper/{favicon_spec.rb → favicon_tag_spec.rb} +7 -11
  33. data/spec/unit/hanami/helpers/assets_helper/{image_spec.rb → image_tag_spec.rb} +8 -12
  34. data/spec/unit/hanami/helpers/assets_helper/{javascript_spec.rb → javascript_tag_spec.rb} +14 -18
  35. data/spec/unit/hanami/helpers/assets_helper/{stylesheet_spec.rb → stylesheet_tag_spec.rb} +12 -16
  36. data/spec/unit/hanami/helpers/assets_helper/{video_spec.rb → video_tag_spec.rb} +11 -11
  37. data/spec/unit/hanami/version_spec.rb +1 -1
  38. metadata +23 -14
@@ -39,15 +39,14 @@ module RSpec
39
39
 
40
40
  def compile_assets!
41
41
  link_node_modules
42
+ generate_assets_config
42
43
 
43
44
  require "hanami/cli/command"
44
45
  require "hanami/cli/commands/app/command"
45
46
  require "hanami/cli/commands/app/assets/compile"
46
- compiler = Hanami::CLI::Commands::App::Assets::Compile.new(config: Hanami.app.config.assets)
47
+ assets_compile = Hanami::CLI::Commands::App::Assets::Compile.new(config: Hanami.app.config.assets)
47
48
 
48
- with_directory(Hanami.app.root) do
49
- compiler.call
50
- end
49
+ with_directory(Hanami.app.root) { assets_compile.call }
51
50
  end
52
51
 
53
52
  def link_node_modules
@@ -58,6 +57,25 @@ module RSpec
58
57
  FileUtils.ln_s(node_modules_path, root)
59
58
  rescue Errno::EEXIST # rubocop:disable Lint/SuppressedException
60
59
  end
60
+
61
+ def generate_assets_config
62
+ root = Hanami.app.root
63
+
64
+ with_directory(root) do
65
+ write("config/assets.mjs", <<~JS) unless root.join("config", "assets.mjs").exist?
66
+ import * as assets from "hanami-assets";
67
+ await assets.run();
68
+ JS
69
+
70
+ write("package.json", <<~JSON) unless root.join("package.json").exist?
71
+ {
72
+ "scripts": {
73
+ "assets": "node config/assets.mjs"
74
+ }
75
+ }
76
+ JSON
77
+ end
78
+ end
61
79
  end
62
80
  end
63
81
  end
@@ -14,8 +14,8 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#audio", :app_integration do
14
14
  }.new(context)
15
15
  }
16
16
 
17
- def audio(...)
18
- subject.audio(...)
17
+ def audio_tag(...)
18
+ subject.audio_tag(...)
19
19
  end
20
20
 
21
21
  let(:context) { TestApp::Views::Context.new }
@@ -53,26 +53,22 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#audio", :app_integration do
53
53
  end
54
54
 
55
55
  it "returns an instance of HtmlBuilder" do
56
- actual = audio("song.ogg")
56
+ actual = audio_tag("song.ogg")
57
57
  expect(actual).to be_instance_of(::Hanami::View::HTML::SafeString)
58
58
  end
59
59
 
60
60
  it "renders <audio> tag" do
61
- actual = audio("song.ogg").to_s
61
+ actual = audio_tag("song.ogg").to_s
62
62
  expect(actual).to eq(%(<audio src="/assets/song.ogg"></audio>))
63
63
  end
64
64
 
65
- it "is aliased as #audio_tag" do
66
- expect(subject.audio_tag("song.ogg")).to eq(audio("song.ogg"))
67
- end
68
-
69
65
  it "renders with html attributes" do
70
- actual = audio("song.ogg", autoplay: true, controls: true).to_s
66
+ actual = audio_tag("song.ogg", autoplay: true, controls: true).to_s
71
67
  expect(actual).to eq(%(<audio autoplay="autoplay" controls="controls" src="/assets/song.ogg"></audio>))
72
68
  end
73
69
 
74
70
  it "renders with fallback content" do
75
- actual = audio("song.ogg") do
71
+ actual = audio_tag("song.ogg") do
76
72
  "Your browser does not support the audio tag"
77
73
  end.to_s
78
74
 
@@ -80,7 +76,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#audio", :app_integration do
80
76
  end
81
77
 
82
78
  it "renders with tracks" do
83
- actual = audio("song.ogg") do
79
+ actual = audio_tag("song.ogg") do
84
80
  tag.track kind: "captions", src: subject.asset_url("song.pt-BR.vtt"), srclang: "pt-BR", label: "Portuguese"
85
81
  end.to_s
86
82
 
@@ -99,7 +95,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#audio", :app_integration do
99
95
 
100
96
  it "raises an exception when no arguments" do
101
97
  expect do
102
- audio
98
+ audio_tag
103
99
  end.to raise_error(
104
100
  ArgumentError,
105
101
  "You should provide a source via `src` option or with a `source` HTML tag"
@@ -108,7 +104,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#audio", :app_integration do
108
104
 
109
105
  it "raises an exception when no src and no block" do
110
106
  expect do
111
- audio(controls: true)
107
+ audio_tag(controls: true)
112
108
  end.to raise_error(
113
109
  ArgumentError,
114
110
  "You should provide a source via `src` option or with a `source` HTML tag"
@@ -123,7 +119,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#audio", :app_integration do
123
119
  end
124
120
 
125
121
  it "returns absolute url for src attribute" do
126
- actual = audio("song.ogg").to_s
122
+ actual = audio_tag("song.ogg").to_s
127
123
  expect(actual).to eq(%(<audio src="#{base_url}/assets/song.ogg"></audio>))
128
124
  end
129
125
  end
@@ -14,8 +14,8 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#favicon", :app_integration do
14
14
  }.new(context)
15
15
  }
16
16
 
17
- def favicon(...)
18
- obj.instance_eval { favicon(...) }
17
+ def favicon_tag(...)
18
+ obj.instance_eval { favicon_tag(...) }
19
19
  end
20
20
 
21
21
  let(:root) { make_tmp_directory }
@@ -53,26 +53,22 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#favicon", :app_integration do
53
53
  end
54
54
 
55
55
  it "returns an instance of SafeString" do
56
- actual = favicon
56
+ actual = favicon_tag
57
57
  expect(actual).to be_instance_of(::Hanami::View::HTML::SafeString)
58
58
  end
59
59
 
60
- it "is aliased as #favicon_link_tag" do
61
- expect(subject.favicon_link_tag).to eq(favicon)
62
- end
63
-
64
60
  it "renders <link> tag" do
65
- actual = favicon.to_s
61
+ actual = favicon_tag.to_s
66
62
  expect(actual).to eq(%(<link href="/assets/favicon.ico" rel="shortcut icon" type="image/x-icon">))
67
63
  end
68
64
 
69
65
  it "renders with HTML attributes" do
70
- actual = favicon("favicon.png", rel: "icon", type: "image/png").to_s
66
+ actual = favicon_tag("favicon.png", rel: "icon", type: "image/png").to_s
71
67
  expect(actual).to eq(%(<link href="/assets/favicon.png" rel="icon" type="image/png">))
72
68
  end
73
69
 
74
70
  it "ignores href passed as an option" do
75
- actual = favicon("favicon.png", href: "wrong").to_s
71
+ actual = favicon_tag("favicon.png", href: "wrong").to_s
76
72
  expect(actual).to eq(%(<link href="/assets/favicon.png" rel="shortcut icon" type="image/x-icon">))
77
73
  end
78
74
 
@@ -84,7 +80,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#favicon", :app_integration do
84
80
  end
85
81
 
86
82
  it "returns absolute url for href attribute" do
87
- actual = favicon.to_s
83
+ actual = favicon_tag.to_s
88
84
  expect(actual).to eq(%(<link href="#{base_url}/assets/favicon.ico" rel="shortcut icon" type="image/x-icon">))
89
85
  end
90
86
  end
@@ -14,8 +14,8 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#image", :app_integration do
14
14
  }.new(context)
15
15
  }
16
16
 
17
- def image(...)
18
- subject.image(...)
17
+ def image_tag(...)
18
+ subject.image_tag(...)
19
19
  end
20
20
 
21
21
  let(:root) { make_tmp_directory }
@@ -53,31 +53,27 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#image", :app_integration do
53
53
  end
54
54
 
55
55
  it "returns an instance of HtmlBuilder" do
56
- actual = image("application.jpg")
56
+ actual = image_tag("application.jpg")
57
57
  expect(actual).to be_instance_of(::Hanami::View::HTML::SafeString)
58
58
  end
59
59
 
60
60
  it "renders an <img> tag" do
61
- actual = image("application.jpg").to_s
61
+ actual = image_tag("application.jpg").to_s
62
62
  expect(actual).to eq(%(<img src="/assets/application.jpg" alt="Application">))
63
63
  end
64
64
 
65
- it "is aliased as #image_tag" do
66
- expect(subject.image_tag("application.jpg")).to eq image("application.jpg")
67
- end
68
-
69
65
  it "custom alt" do
70
- actual = image("application.jpg", alt: "My Alt").to_s
66
+ actual = image_tag("application.jpg", alt: "My Alt").to_s
71
67
  expect(actual).to eq(%(<img src="/assets/application.jpg" alt="My Alt">))
72
68
  end
73
69
 
74
70
  it "custom data attribute" do
75
- actual = image("application.jpg", "data-user-id" => 5).to_s
71
+ actual = image_tag("application.jpg", "data-user-id" => 5).to_s
76
72
  expect(actual).to eq(%(<img src="/assets/application.jpg" alt="Application" data-user-id="5">))
77
73
  end
78
74
 
79
75
  it "ignores src passed as an option" do
80
- actual = image("application.jpg", src: "wrong").to_s
76
+ actual = image_tag("application.jpg", src: "wrong").to_s
81
77
  expect(actual).to eq(%(<img src="/assets/application.jpg" alt="Application">))
82
78
  end
83
79
 
@@ -89,7 +85,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#image", :app_integration do
89
85
  end
90
86
 
91
87
  it "returns absolute url for src attribute" do
92
- actual = image("application.jpg").to_s
88
+ actual = image_tag("application.jpg").to_s
93
89
  expect(actual).to eq(%(<img src="#{base_url}/assets/application.jpg" alt="Application">))
94
90
  end
95
91
  end
@@ -14,8 +14,8 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#javascript", :app_integration do
14
14
  }.new(context)
15
15
  }
16
16
 
17
- def javascript(...)
18
- subject.javascript(...)
17
+ def javascript_tag(...)
18
+ subject.javascript_tag(...)
19
19
  end
20
20
 
21
21
  let(:context) { TestApp::Views::Context.new }
@@ -65,56 +65,52 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#javascript", :app_integration do
65
65
  end
66
66
 
67
67
  it "returns an instance of SafeString" do
68
- actual = javascript("feature-a")
68
+ actual = javascript_tag("feature-a")
69
69
  expect(actual).to be_instance_of(::Hanami::View::HTML::SafeString)
70
70
  end
71
71
 
72
- it "is aliased as #js" do
73
- expect(subject.js("feature-a")).to eq javascript("feature-a")
74
- end
75
-
76
72
  it "is aliased as #javascript_tag" do
77
- expect(subject.javascript_tag("feature-a")).to eq javascript("feature-a")
73
+ expect(subject.javascript_tag("feature-a")).to eq javascript_tag("feature-a")
78
74
  end
79
75
 
80
76
  it "renders <script> tag" do
81
- actual = javascript("feature-a")
77
+ actual = javascript_tag("feature-a")
82
78
  expect(actual).to eq(%(<script src="/assets/feature-a.js" type="text/javascript"></script>))
83
79
  end
84
80
 
85
81
  xit "renders <script> tag without appending ext after query string" do
86
- actual = javascript("feature-x?callback=init")
82
+ actual = javascript_tag("feature-x?callback=init")
87
83
  expect(actual).to eq(%(<script src="/assets/feature-x?callback=init" type="text/javascript"></script>))
88
84
  end
89
85
 
90
86
  it "renders <script> tag with a defer attribute" do
91
- actual = javascript("feature-a", defer: true)
87
+ actual = javascript_tag("feature-a", defer: true)
92
88
  expect(actual).to eq(%(<script src="/assets/feature-a.js" type="text/javascript" defer="defer"></script>))
93
89
  end
94
90
 
95
91
  it "renders <script> tag with an integrity attribute" do
96
- actual = javascript("feature-a", integrity: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC")
92
+ actual = javascript_tag("feature-a", integrity: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC")
97
93
  expect(actual).to eq(%(<script src="/assets/feature-a.js" type="text/javascript" integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" crossorigin="anonymous"></script>))
98
94
  end
99
95
 
100
96
  it "renders <script> tag with a crossorigin attribute" do
101
- actual = javascript("feature-a", integrity: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC", crossorigin: "use-credentials")
97
+ actual = javascript_tag("feature-a", integrity: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC", crossorigin: "use-credentials")
102
98
  expect(actual).to eq(%(<script src="/assets/feature-a.js" type="text/javascript" integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" crossorigin="use-credentials"></script>))
103
99
  end
104
100
 
105
101
  it "ignores src passed as an option" do
106
- actual = javascript("feature-a", src: "wrong")
102
+ actual = javascript_tag("feature-a", src: "wrong")
107
103
  expect(actual).to eq(%(<script src="/assets/feature-a.js" type="text/javascript"></script>))
108
104
  end
109
105
 
110
106
  describe "async option" do
111
107
  it "renders <script> tag with an async=true if async option is true" do
112
- actual = javascript("feature-a", async: true)
108
+ actual = javascript_tag("feature-a", async: true)
113
109
  expect(actual).to eq(%(<script src="/assets/feature-a.js" type="text/javascript" async="async"></script>))
114
110
  end
115
111
 
116
112
  it "renders <script> tag without an async=true if async option is false" do
117
- actual = javascript("feature-a", async: false)
113
+ actual = javascript_tag("feature-a", async: false)
118
114
  expect(actual).to eq(%(<script src="/assets/feature-a.js" type="text/javascript"></script>))
119
115
  end
120
116
  end
@@ -127,7 +123,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#javascript", :app_integration do
127
123
  before { compile_assets! }
128
124
 
129
125
  it "includes subresource_integrity and crossorigin attributes" do
130
- actual = javascript("app")
126
+ actual = javascript_tag("app")
131
127
  expect(actual).to match(%r{<script src="/assets/app-[A-Z0-9]{8}.js" type="text/javascript" integrity="sha384-[A-Za-z0-9+/]{64}" crossorigin="anonymous"></script>})
132
128
  end
133
129
  end
@@ -140,7 +136,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#javascript", :app_integration do
140
136
  end
141
137
 
142
138
  it "returns absolute url for src attribute" do
143
- actual = javascript("feature-a")
139
+ actual = javascript_tag("feature-a")
144
140
  expect(actual).to eq(%(<script src="#{base_url}/assets/feature-a.js" type="text/javascript"></script>))
145
141
  end
146
142
  end
@@ -14,8 +14,8 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#stylesheet", :app_integration do
14
14
  }.new(context)
15
15
  }
16
16
 
17
- def stylesheet(...)
18
- subject.stylesheet(...)
17
+ def stylesheet_tag(...)
18
+ subject.stylesheet_tag(...)
19
19
  end
20
20
 
21
21
  let(:context) { TestApp::Views::Context.new }
@@ -65,40 +65,36 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#stylesheet", :app_integration do
65
65
  end
66
66
 
67
67
  it "returns an instance of SafeString" do
68
- actual = stylesheet("main")
68
+ actual = stylesheet_tag("main")
69
69
  expect(actual).to be_instance_of(::Hanami::View::HTML::SafeString)
70
70
  end
71
71
 
72
- it "is aliased as #css" do
73
- expect(subject.css("main")).to eq stylesheet("main")
74
- end
75
-
76
- it "is aliased as #stylesheet_link_tag" do
77
- expect(subject.stylesheet_link_tag("main")).to eq stylesheet("main")
72
+ it "is aliased as #stylesheet_tag" do
73
+ expect(subject.stylesheet_tag("main")).to eq stylesheet_tag("main")
78
74
  end
79
75
 
80
76
  it "renders <link> tag" do
81
- actual = stylesheet("main")
77
+ actual = stylesheet_tag("main")
82
78
  expect(actual).to eq(%(<link href="/assets/main.css" type="text/css" rel="stylesheet">))
83
79
  end
84
80
 
85
81
  xit "renders <link> tag without appending ext after query string" do
86
- actual = stylesheet("fonts?font=Helvetica")
82
+ actual = stylesheet_tag("fonts?font=Helvetica")
87
83
  expect(actual).to eq(%(<link href="/assets/fonts?font=Helvetica" type="text/css" rel="stylesheet">))
88
84
  end
89
85
 
90
86
  it "renders <link> tag with an integrity attribute" do
91
- actual = stylesheet("main", integrity: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC")
87
+ actual = stylesheet_tag("main", integrity: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC")
92
88
  expect(actual).to eq(%(<link href="/assets/main.css" type="text/css" rel="stylesheet" integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" crossorigin="anonymous">))
93
89
  end
94
90
 
95
91
  it "renders <link> tag with a crossorigin attribute" do
96
- actual = stylesheet("main", integrity: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC", crossorigin: "use-credentials")
92
+ actual = stylesheet_tag("main", integrity: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC", crossorigin: "use-credentials")
97
93
  expect(actual).to eq(%(<link href="/assets/main.css" type="text/css" rel="stylesheet" integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC" crossorigin="use-credentials">))
98
94
  end
99
95
 
100
96
  it "ignores href passed as an option" do
101
- actual = stylesheet("main", href: "wrong")
97
+ actual = stylesheet_tag("main", href: "wrong")
102
98
  expect(actual).to eq(%(<link href="/assets/main.css" type="text/css" rel="stylesheet">))
103
99
  end
104
100
 
@@ -110,7 +106,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#stylesheet", :app_integration do
110
106
  before { compile_assets! }
111
107
 
112
108
  it "includes subresource_integrity and crossorigin attributes" do
113
- actual = stylesheet("app")
109
+ actual = stylesheet_tag("app")
114
110
  expect(actual).to match(%r{<link href="/assets/app-[A-Z0-9]{8}.css" type="text/css" rel="stylesheet" integrity="sha384-[A-Za-z0-9+/]{64}" crossorigin="anonymous">})
115
111
  end
116
112
  end
@@ -123,7 +119,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#stylesheet", :app_integration do
123
119
  end
124
120
 
125
121
  it "returns absolute url for href attribute" do
126
- actual = stylesheet("main")
122
+ actual = stylesheet_tag("main")
127
123
  expect(actual).to eq(%(<link href="#{base_url}/assets/main.css" type="text/css" rel="stylesheet">))
128
124
  end
129
125
  end
@@ -14,8 +14,8 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#video", :app_integration do
14
14
  }.new(context)
15
15
  }
16
16
 
17
- def video(...)
18
- subject.video(...)
17
+ def video_tag(...)
18
+ subject.video_tag(...)
19
19
  end
20
20
 
21
21
  let(:context) { TestApp::Views::Context.new }
@@ -53,26 +53,26 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#video", :app_integration do
53
53
  end
54
54
 
55
55
  it "returns an instance of HtmlBuilder" do
56
- actual = video("movie.mp4")
56
+ actual = video_tag("movie.mp4")
57
57
  expect(actual).to be_instance_of(::Hanami::View::HTML::SafeString)
58
58
  end
59
59
 
60
60
  it "renders <video> tag" do
61
- actual = video("movie.mp4").to_s
61
+ actual = video_tag("movie.mp4").to_s
62
62
  expect(actual).to eq(%(<video src="/assets/movie.mp4"></video>))
63
63
  end
64
64
 
65
65
  it "is aliased as #video_tag" do
66
- expect(video("movie.mp4")).to eq(subject.video_tag("movie.mp4"))
66
+ expect(video_tag("movie.mp4")).to eq(subject.video_tag("movie.mp4"))
67
67
  end
68
68
 
69
69
  it "renders with html attributes" do
70
- actual = video("movie.mp4", autoplay: true, controls: true).to_s
70
+ actual = video_tag("movie.mp4", autoplay: true, controls: true).to_s
71
71
  expect(actual).to eq(%(<video autoplay="autoplay" controls="controls" src="/assets/movie.mp4"></video>))
72
72
  end
73
73
 
74
74
  it "renders with fallback content" do
75
- actual = video("movie.mp4") do
75
+ actual = video_tag("movie.mp4") do
76
76
  "Your browser does not support the video tag"
77
77
  end.to_s
78
78
 
@@ -80,7 +80,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#video", :app_integration do
80
80
  end
81
81
 
82
82
  it "renders with tracks" do
83
- actual = video("movie.mp4") do
83
+ actual = video_tag("movie.mp4") do
84
84
  tag.track kind: "captions", src: subject.asset_url("movie.en.vtt"), srclang: "en", label: "English"
85
85
  end.to_s
86
86
 
@@ -99,7 +99,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#video", :app_integration do
99
99
 
100
100
  it "raises an exception when no arguments" do
101
101
  expect do
102
- video
102
+ video_tag
103
103
  end.to raise_error(
104
104
  ArgumentError,
105
105
  "You should provide a source via `src` option or with a `source` HTML tag"
@@ -108,7 +108,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#video", :app_integration do
108
108
 
109
109
  it "raises an exception when no src and no block" do
110
110
  expect do
111
- video(content: true)
111
+ video_tag(content: true)
112
112
  end.to raise_error(
113
113
  ArgumentError,
114
114
  "You should provide a source via `src` option or with a `source` HTML tag"
@@ -123,7 +123,7 @@ RSpec.describe Hanami::Helpers::AssetsHelper, "#video", :app_integration do
123
123
  end
124
124
 
125
125
  it "returns absolute url for src attribute" do
126
- actual = video("movie.mp4").to_s
126
+ actual = video_tag("movie.mp4").to_s
127
127
  expect(actual).to eq(%(<video src="#{base_url}/assets/movie.mp4"></video>))
128
128
  end
129
129
  end
@@ -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.1.0.beta2.1")
5
+ expect(Hanami::VERSION).to eq("2.1.0.rc1")
6
6
  end
7
7
  end
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.1.0.beta2.1
4
+ version: 2.1.0.rc1
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-10-04 00:00:00.000000000 Z
11
+ date: 2023-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -279,6 +279,7 @@ files:
279
279
  - lib/hanami/extensions/view/scope.rb
280
280
  - lib/hanami/extensions/view/slice_configured_context.rb
281
281
  - lib/hanami/extensions/view/slice_configured_helpers.rb
282
+ - lib/hanami/extensions/view/slice_configured_part.rb
282
283
  - lib/hanami/extensions/view/slice_configured_view.rb
283
284
  - lib/hanami/extensions/view/standard_helpers.rb
284
285
  - lib/hanami/helpers/assets_helper.rb
@@ -311,6 +312,8 @@ files:
311
312
  - lib/hanami/slice_registrar.rb
312
313
  - lib/hanami/version.rb
313
314
  - lib/hanami/web/rack_logger.rb
315
+ - lib/hanami/web/welcome.html.erb
316
+ - lib/hanami/web/welcome.rb
314
317
  - spec/integration/action/cookies_spec.rb
315
318
  - spec/integration/action/csrf_protection_spec.rb
316
319
  - spec/integration/action/format_config_spec.rb
@@ -341,6 +344,7 @@ files:
341
344
  - spec/integration/logging/notifications_spec.rb
342
345
  - spec/integration/logging/request_logging_spec.rb
343
346
  - spec/integration/rack_app/body_parser_spec.rb
347
+ - spec/integration/rack_app/method_override_spec.rb
344
348
  - spec/integration/rack_app/middleware_spec.rb
345
349
  - spec/integration/rack_app/non_booted_rack_app_spec.rb
346
350
  - spec/integration/rack_app/rack_app_spec.rb
@@ -376,10 +380,12 @@ files:
376
380
  - spec/integration/view/helpers/scope_helpers_spec.rb
377
381
  - spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb
378
382
  - spec/integration/view/helpers/user_defined_helpers/scope_helpers_spec.rb
383
+ - spec/integration/view/parts/default_rendering_spec.rb
379
384
  - spec/integration/view/slice_configuration_spec.rb
380
385
  - spec/integration/view/views_spec.rb
381
386
  - spec/integration/web/render_detailed_errors_spec.rb
382
387
  - spec/integration/web/render_errors_spec.rb
388
+ - spec/integration/web/welcome_view_spec.rb
383
389
  - spec/spec_helper.rb
384
390
  - spec/support/app_integration.rb
385
391
  - spec/support/coverage.rb
@@ -406,12 +412,12 @@ files:
406
412
  - spec/unit/hanami/env_spec.rb
407
413
  - spec/unit/hanami/extensions/view/context_spec.rb
408
414
  - spec/unit/hanami/helpers/assets_helper/asset_url_spec.rb
409
- - spec/unit/hanami/helpers/assets_helper/audio_spec.rb
410
- - spec/unit/hanami/helpers/assets_helper/favicon_spec.rb
411
- - spec/unit/hanami/helpers/assets_helper/image_spec.rb
412
- - spec/unit/hanami/helpers/assets_helper/javascript_spec.rb
413
- - spec/unit/hanami/helpers/assets_helper/stylesheet_spec.rb
414
- - spec/unit/hanami/helpers/assets_helper/video_spec.rb
415
+ - spec/unit/hanami/helpers/assets_helper/audio_tag_spec.rb
416
+ - spec/unit/hanami/helpers/assets_helper/favicon_tag_spec.rb
417
+ - spec/unit/hanami/helpers/assets_helper/image_tag_spec.rb
418
+ - spec/unit/hanami/helpers/assets_helper/javascript_tag_spec.rb
419
+ - spec/unit/hanami/helpers/assets_helper/stylesheet_tag_spec.rb
420
+ - spec/unit/hanami/helpers/assets_helper/video_tag_spec.rb
415
421
  - spec/unit/hanami/helpers/form_helper_spec.rb
416
422
  - spec/unit/hanami/port_spec.rb
417
423
  - spec/unit/hanami/router/errors/not_allowed_error_spec.rb
@@ -479,6 +485,7 @@ test_files:
479
485
  - spec/integration/logging/notifications_spec.rb
480
486
  - spec/integration/logging/request_logging_spec.rb
481
487
  - spec/integration/rack_app/body_parser_spec.rb
488
+ - spec/integration/rack_app/method_override_spec.rb
482
489
  - spec/integration/rack_app/middleware_spec.rb
483
490
  - spec/integration/rack_app/non_booted_rack_app_spec.rb
484
491
  - spec/integration/rack_app/rack_app_spec.rb
@@ -514,10 +521,12 @@ test_files:
514
521
  - spec/integration/view/helpers/scope_helpers_spec.rb
515
522
  - spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb
516
523
  - spec/integration/view/helpers/user_defined_helpers/scope_helpers_spec.rb
524
+ - spec/integration/view/parts/default_rendering_spec.rb
517
525
  - spec/integration/view/slice_configuration_spec.rb
518
526
  - spec/integration/view/views_spec.rb
519
527
  - spec/integration/web/render_detailed_errors_spec.rb
520
528
  - spec/integration/web/render_errors_spec.rb
529
+ - spec/integration/web/welcome_view_spec.rb
521
530
  - spec/spec_helper.rb
522
531
  - spec/support/app_integration.rb
523
532
  - spec/support/coverage.rb
@@ -544,12 +553,12 @@ test_files:
544
553
  - spec/unit/hanami/env_spec.rb
545
554
  - spec/unit/hanami/extensions/view/context_spec.rb
546
555
  - spec/unit/hanami/helpers/assets_helper/asset_url_spec.rb
547
- - spec/unit/hanami/helpers/assets_helper/audio_spec.rb
548
- - spec/unit/hanami/helpers/assets_helper/favicon_spec.rb
549
- - spec/unit/hanami/helpers/assets_helper/image_spec.rb
550
- - spec/unit/hanami/helpers/assets_helper/javascript_spec.rb
551
- - spec/unit/hanami/helpers/assets_helper/stylesheet_spec.rb
552
- - spec/unit/hanami/helpers/assets_helper/video_spec.rb
556
+ - spec/unit/hanami/helpers/assets_helper/audio_tag_spec.rb
557
+ - spec/unit/hanami/helpers/assets_helper/favicon_tag_spec.rb
558
+ - spec/unit/hanami/helpers/assets_helper/image_tag_spec.rb
559
+ - spec/unit/hanami/helpers/assets_helper/javascript_tag_spec.rb
560
+ - spec/unit/hanami/helpers/assets_helper/stylesheet_tag_spec.rb
561
+ - spec/unit/hanami/helpers/assets_helper/video_tag_spec.rb
553
562
  - spec/unit/hanami/helpers/form_helper_spec.rb
554
563
  - spec/unit/hanami/port_spec.rb
555
564
  - spec/unit/hanami/router/errors/not_allowed_error_spec.rb