hanami 2.1.0.beta2.1 → 2.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/hanami.gemspec +3 -3
  4. data/lib/hanami/config/actions.rb +16 -3
  5. data/lib/hanami/config/assets.rb +1 -1
  6. data/lib/hanami/config/views.rb +10 -2
  7. data/lib/hanami/config.rb +21 -12
  8. data/lib/hanami/extensions/action/slice_configured_action.rb +5 -5
  9. data/lib/hanami/extensions/action.rb +4 -4
  10. data/lib/hanami/extensions/view/context.rb +111 -19
  11. data/lib/hanami/extensions/view/part.rb +64 -3
  12. data/lib/hanami/extensions/view/scope.rb +7 -0
  13. data/lib/hanami/extensions/view/slice_configured_context.rb +12 -8
  14. data/lib/hanami/extensions/view/slice_configured_helpers.rb +12 -1
  15. data/lib/hanami/extensions/view/slice_configured_part.rb +71 -0
  16. data/lib/hanami/extensions/view/slice_configured_view.rb +14 -6
  17. data/lib/hanami/extensions/view/standard_helpers.rb +4 -0
  18. data/lib/hanami/extensions/view.rb +5 -3
  19. data/lib/hanami/helpers/assets_helper.rb +47 -79
  20. data/lib/hanami/routes.rb +33 -2
  21. data/lib/hanami/slice.rb +12 -2
  22. data/lib/hanami/slice_registrar.rb +48 -23
  23. data/lib/hanami/version.rb +1 -1
  24. data/lib/hanami/web/rack_logger.rb +70 -2
  25. data/lib/hanami/web/welcome.html.erb +203 -0
  26. data/lib/hanami/web/welcome.rb +46 -0
  27. data/spec/integration/assets/assets_spec.rb +14 -3
  28. data/spec/integration/logging/request_logging_spec.rb +65 -7
  29. data/spec/integration/rack_app/method_override_spec.rb +97 -0
  30. data/spec/integration/slices_spec.rb +275 -5
  31. data/spec/integration/view/context/assets_spec.rb +0 -8
  32. data/spec/integration/view/context/inflector_spec.rb +0 -8
  33. data/spec/integration/view/context/settings_spec.rb +0 -8
  34. data/spec/integration/view/helpers/part_helpers_spec.rb +2 -2
  35. data/spec/integration/view/helpers/user_defined_helpers/part_helpers_spec.rb +10 -10
  36. data/spec/integration/view/parts/default_rendering_spec.rb +138 -0
  37. data/spec/integration/web/welcome_view_spec.rb +84 -0
  38. data/spec/support/app_integration.rb +22 -4
  39. data/spec/unit/hanami/config/render_detailed_errors_spec.rb +1 -1
  40. data/spec/unit/hanami/helpers/assets_helper/{audio_spec.rb → audio_tag_spec.rb} +10 -14
  41. data/spec/unit/hanami/helpers/assets_helper/{favicon_spec.rb → favicon_tag_spec.rb} +7 -11
  42. data/spec/unit/hanami/helpers/assets_helper/{image_spec.rb → image_tag_spec.rb} +8 -12
  43. data/spec/unit/hanami/helpers/assets_helper/{javascript_spec.rb → javascript_tag_spec.rb} +14 -18
  44. data/spec/unit/hanami/helpers/assets_helper/{stylesheet_spec.rb → stylesheet_tag_spec.rb} +12 -16
  45. data/spec/unit/hanami/helpers/assets_helper/{video_spec.rb → video_tag_spec.rb} +11 -11
  46. data/spec/unit/hanami/version_spec.rb +1 -1
  47. metadata +28 -19
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "rack/test"
5
+
6
+ RSpec.describe "Web / Welcome view", :app_integration do
7
+ include Rack::Test::Methods
8
+
9
+ let(:app) { Hanami.app }
10
+
11
+ before do
12
+ with_directory(@dir = make_tmp_directory) do
13
+ write "config/app.rb", <<~RUBY
14
+ require "hanami"
15
+
16
+ module TestApp
17
+ class App < Hanami::App
18
+ config.logger.stream = File::NULL
19
+ end
20
+ end
21
+ RUBY
22
+
23
+ write "config/routes.rb", <<~RUBY
24
+ module TestApp
25
+ class Routes < Hanami::Routes
26
+ end
27
+ end
28
+ RUBY
29
+
30
+ before_prepare if respond_to?(:before_prepare)
31
+ require "hanami/prepare"
32
+ end
33
+ end
34
+
35
+ context "no routes defined" do
36
+ it "renders the welcome page" do
37
+ get "/"
38
+
39
+ body = last_response.body.strip
40
+ expect(body).to include "<h1>Welcome to Hanami</h1>"
41
+ expect(body).to include "Hanami version: #{Hanami::VERSION}"
42
+ expect(body).to include "Ruby version: #{RUBY_DESCRIPTION}"
43
+
44
+ expect(last_response.status).to eq 200
45
+ end
46
+ end
47
+
48
+ context "routes defined" do
49
+ def before_prepare
50
+ write "config/routes.rb", <<~RUBY
51
+ module TestApp
52
+ class Routes < Hanami::Routes
53
+ root to: -> * { [200, {}, "Hello from a route"] }
54
+ end
55
+ end
56
+ RUBY
57
+ end
58
+
59
+ it "does not render the welcome page" do
60
+ get "/"
61
+
62
+ expect(last_response.body).to eq "Hello from a route"
63
+ expect(last_response.status).to eq 200
64
+ end
65
+ end
66
+
67
+ context "non-development env" do
68
+ def before_prepare
69
+ @hanami_env = ENV["HANAMI_ENV"]
70
+ ENV["HANAMI_ENV"] = "production"
71
+ end
72
+
73
+ after do
74
+ ENV["HANAMI_ENV"] = @hanami_env
75
+ end
76
+
77
+ it "does not render the welcome page" do
78
+ get "/"
79
+
80
+ expect(last_response.body).to eq "Not Found"
81
+ expect(last_response.status).to eq 404
82
+ end
83
+ end
84
+ end
@@ -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
@@ -15,7 +15,7 @@ RSpec.describe Hanami::Config, "#render_detailed_errors" do
15
15
 
16
16
  context "test mode" do
17
17
  let(:env) { :test }
18
- it { is_expected.to be true }
18
+ it { is_expected.to be false }
19
19
  end
20
20
 
21
21
  context "production mode" do
@@ -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.rc2")
6
6
  end
7
7
  end