jekyll-minibundle 2.1.1 → 2.1.2
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 +29 -0
- data/README.md +6 -2
- data/jekyll-minibundle.gemspec +1 -1
- data/lib/jekyll/minibundle/asset_bundle.rb +10 -5
- data/lib/jekyll/minibundle/asset_file_properties.rb +1 -5
- data/lib/jekyll/minibundle/asset_tag_markup.rb +3 -12
- data/lib/jekyll/minibundle/bundle_file.rb +25 -16
- data/lib/jekyll/minibundle/development_file.rb +14 -4
- data/lib/jekyll/minibundle/files.rb +22 -9
- data/lib/jekyll/minibundle/mini_bundle_block.rb +14 -10
- data/lib/jekyll/minibundle/mini_stamp_tag.rb +2 -1
- data/lib/jekyll/minibundle/stamp_file.rb +21 -9
- data/lib/jekyll/minibundle/version.rb +1 -1
- data/test/fixture/site/_layouts/default.html +1 -1
- data/test/integration/minibundle_development_mode_test.rb +18 -3
- data/test/integration/minibundle_production_mode_test.rb +108 -4
- data/test/integration/ministamp_development_mode_test.rb +13 -6
- data/test/integration/ministamp_production_mode_test.rb +63 -4
- data/test/support/static_file_api_config.rb +1 -0
- data/test/support/test_case.rb +4 -4
- data/test/unit/asset_bundle_test.rb +15 -8
- data/test/unit/asset_file_registry_test.rb +3 -3
- data/test/unit/asset_tag_markup_test.rb +5 -17
- data/test/unit/bundle_file_properties_test.rb +4 -0
- data/test/unit/bundle_file_writing_test.rb +54 -18
- data/test/unit/development_file_collection_properties_test.rb +5 -0
- data/test/unit/development_file_writing_test.rb +39 -0
- data/test/unit/environment_test.rb +4 -4
- data/test/unit/files_test.rb +13 -0
- data/test/unit/jekyll_static_file_api_test.rb +1 -1
- data/test/unit/mini_bundle_block_test.rb +1 -1
- data/test/unit/mini_stamp_tag_test.rb +1 -1
- data/test/unit/stamp_file_properties_test.rb +4 -0
- data/test/unit/stamp_file_writing_test.rb +54 -18
- metadata +7 -6
- data/lib/jekyll/minibundle/asset_file_operations.rb +0 -16
@@ -1,6 +1,7 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
+
<title>{{ page.title }}</title>
|
4
5
|
<link rel="stylesheet" href="{% ministamp _tmp/site.css assets/screen.css %}" media="screen">
|
5
6
|
{% minibundle css %}
|
6
7
|
source_dir: _assets/styles
|
@@ -25,5 +26,4 @@
|
|
25
26
|
async:
|
26
27
|
{% endminibundle %}
|
27
28
|
</body>
|
28
|
-
<title>{{ page.title }}</title>
|
29
29
|
</html>
|
@@ -190,16 +190,31 @@ module Jekyll::Minibundle::Test
|
|
190
190
|
with_site_dir do
|
191
191
|
generate_site(:development)
|
192
192
|
|
193
|
-
|
194
|
-
|
193
|
+
destination_css = destination_path(CSS_BUNDLE_DESTINATION_PATH, 'common.css')
|
194
|
+
destination_js = destination_path(JS_BUNDLE_DESTINATION_PATH, 'app.js')
|
195
|
+
org_mtime_css = file_mtime_of(destination_css)
|
196
|
+
org_mtime_js = file_mtime_of(destination_js)
|
197
|
+
|
198
|
+
assert File.exist?(destination_css)
|
199
|
+
assert File.exist?(destination_js)
|
195
200
|
|
196
201
|
assert_equal 'assets/site/common.css', find_css_paths_from_index.last
|
197
202
|
assert_equal 'assets/site/app.js', find_js_paths_from_index.last
|
198
203
|
|
199
|
-
|
204
|
+
ensure_file_mtime_changes do
|
205
|
+
find_and_gsub_in_file(
|
206
|
+
source_path('_layouts/default.html'),
|
207
|
+
'destination_path: assets/site',
|
208
|
+
'destination_path: /assets/site'
|
209
|
+
)
|
210
|
+
end
|
200
211
|
|
201
212
|
generate_site(:development, clear_cache: false)
|
202
213
|
|
214
|
+
assert File.exist?(destination_css)
|
215
|
+
assert File.exist?(destination_js)
|
216
|
+
assert_equal org_mtime_css, file_mtime_of(destination_css)
|
217
|
+
assert_equal org_mtime_js, file_mtime_of(destination_js)
|
203
218
|
assert_equal '/assets/site/common.css', find_css_paths_from_index.last
|
204
219
|
assert_equal '/assets/site/app.js', find_js_paths_from_index.last
|
205
220
|
end
|
@@ -314,16 +314,31 @@ module Jekyll::Minibundle::Test
|
|
314
314
|
with_site_dir do
|
315
315
|
generate_site(:production)
|
316
316
|
|
317
|
-
|
318
|
-
|
317
|
+
destination_css = destination_path(CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH)
|
318
|
+
destination_js = destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH)
|
319
|
+
org_mtime_css = file_mtime_of(destination_css)
|
320
|
+
org_mtime_js = file_mtime_of(destination_js)
|
321
|
+
|
322
|
+
assert File.exist?(destination_css)
|
323
|
+
assert File.exist?(destination_js)
|
319
324
|
|
320
325
|
assert_equal CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
321
326
|
assert_equal JS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_js_path_from_index
|
322
327
|
|
323
|
-
|
328
|
+
ensure_file_mtime_changes do
|
329
|
+
find_and_gsub_in_file(
|
330
|
+
source_path('_layouts/default.html'),
|
331
|
+
'destination_path: assets/site',
|
332
|
+
'destination_path: /assets/site'
|
333
|
+
)
|
334
|
+
end
|
324
335
|
|
325
336
|
generate_site(:production, clear_cache: false)
|
326
337
|
|
338
|
+
assert File.exist?(destination_css)
|
339
|
+
assert File.exist?(destination_js)
|
340
|
+
assert_equal org_mtime_css, file_mtime_of(destination_css)
|
341
|
+
assert_equal org_mtime_js, file_mtime_of(destination_js)
|
327
342
|
assert_equal "/#{CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH}", find_css_path_from_index
|
328
343
|
assert_equal "/#{JS_BUNDLE_DESTINATION_FINGERPRINT_PATH}", find_js_path_from_index
|
329
344
|
end
|
@@ -365,6 +380,96 @@ module Jekyll::Minibundle::Test
|
|
365
380
|
end
|
366
381
|
end
|
367
382
|
|
383
|
+
def test_strips_dot_slash_from_dot_baseurl
|
384
|
+
with_site_dir do
|
385
|
+
find_and_gsub_in_file(source_path('_layouts/default.html'), '{% minibundle css %}', "{% minibundle css %}\n baseurl: .")
|
386
|
+
find_and_gsub_in_file(source_path('_layouts/default.html'), '{% minibundle js %}', "{% minibundle js %}\n baseurl: .")
|
387
|
+
|
388
|
+
generate_site(:production)
|
389
|
+
|
390
|
+
assert File.exist?(destination_path(CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
391
|
+
assert File.exist?(destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
392
|
+
|
393
|
+
assert_equal CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
394
|
+
assert_equal JS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_js_path_from_index
|
395
|
+
|
396
|
+
generate_site(:production, clear_cache: false)
|
397
|
+
|
398
|
+
assert File.exist?(destination_path(CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
399
|
+
assert File.exist?(destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
400
|
+
|
401
|
+
assert_equal CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
402
|
+
assert_equal JS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_js_path_from_index
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
def test_strips_dot_slash_from_dot_slash_baseurl
|
407
|
+
with_site_dir do
|
408
|
+
find_and_gsub_in_file(source_path('_layouts/default.html'), '{% minibundle css %}', "{% minibundle css %}\n baseurl: ./")
|
409
|
+
find_and_gsub_in_file(source_path('_layouts/default.html'), '{% minibundle js %}', "{% minibundle js %}\n baseurl: ./")
|
410
|
+
|
411
|
+
generate_site(:production)
|
412
|
+
|
413
|
+
assert File.exist?(destination_path(CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
414
|
+
assert File.exist?(destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
415
|
+
|
416
|
+
assert_equal CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
417
|
+
assert_equal JS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_js_path_from_index
|
418
|
+
|
419
|
+
generate_site(:production, clear_cache: false)
|
420
|
+
|
421
|
+
assert File.exist?(destination_path(CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
422
|
+
assert File.exist?(destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
|
423
|
+
|
424
|
+
assert_equal CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
425
|
+
assert_equal JS_BUNDLE_DESTINATION_FINGERPRINT_PATH, find_js_path_from_index
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
def test_strips_dot_slash_from_relative_destination_path
|
430
|
+
with_site_dir do
|
431
|
+
find_and_gsub_in_file(source_path('_layouts/default.html'), 'destination_path: assets/site', 'destination_path: site')
|
432
|
+
|
433
|
+
generate_site(:production)
|
434
|
+
|
435
|
+
assert File.exist?(destination_path("site-#{CSS_BUNDLE_FINGERPRINT}.css"))
|
436
|
+
assert File.exist?(destination_path("site-#{JS_BUNDLE_FINGERPRINT}.js"))
|
437
|
+
|
438
|
+
assert_equal "site-#{CSS_BUNDLE_FINGERPRINT}.css", find_css_path_from_index
|
439
|
+
assert_equal "site-#{JS_BUNDLE_FINGERPRINT}.js", find_js_path_from_index
|
440
|
+
|
441
|
+
generate_site(:production, clear_cache: false)
|
442
|
+
|
443
|
+
assert File.exist?(destination_path("site-#{CSS_BUNDLE_FINGERPRINT}.css"))
|
444
|
+
assert File.exist?(destination_path("site-#{JS_BUNDLE_FINGERPRINT}.js"))
|
445
|
+
|
446
|
+
assert_equal "site-#{CSS_BUNDLE_FINGERPRINT}.css", find_css_path_from_index
|
447
|
+
assert_equal "site-#{JS_BUNDLE_FINGERPRINT}.js", find_js_path_from_index
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
def test_strips_dot_slash_from_dot_slash_destination_path
|
452
|
+
with_site_dir do
|
453
|
+
find_and_gsub_in_file(source_path('_layouts/default.html'), 'destination_path: assets/site', 'destination_path: ./site')
|
454
|
+
|
455
|
+
generate_site(:production)
|
456
|
+
|
457
|
+
assert File.exist?(destination_path("site-#{CSS_BUNDLE_FINGERPRINT}.css"))
|
458
|
+
assert File.exist?(destination_path("site-#{JS_BUNDLE_FINGERPRINT}.js"))
|
459
|
+
|
460
|
+
assert_equal "site-#{CSS_BUNDLE_FINGERPRINT}.css", find_css_path_from_index
|
461
|
+
assert_equal "site-#{JS_BUNDLE_FINGERPRINT}.js", find_js_path_from_index
|
462
|
+
|
463
|
+
generate_site(:production, clear_cache: false)
|
464
|
+
|
465
|
+
assert File.exist?(destination_path("site-#{CSS_BUNDLE_FINGERPRINT}.css"))
|
466
|
+
assert File.exist?(destination_path("site-#{JS_BUNDLE_FINGERPRINT}.js"))
|
467
|
+
|
468
|
+
assert_equal "site-#{CSS_BUNDLE_FINGERPRINT}.css", find_css_path_from_index
|
469
|
+
assert_equal "site-#{JS_BUNDLE_FINGERPRINT}.js", find_js_path_from_index
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
368
473
|
def test_supports_changing_attributes
|
369
474
|
with_site_dir do
|
370
475
|
generate_site(:production)
|
@@ -505,7 +610,6 @@ title: Test
|
|
505
610
|
minifier_cmd: #{minifier_cmd_to_remove_comments_and_count('minifier_cmd_local_count')}
|
506
611
|
{% endminibundle %}
|
507
612
|
</body>
|
508
|
-
<title>{{ page.title }}</title>
|
509
613
|
</html>
|
510
614
|
END
|
511
615
|
|
@@ -141,17 +141,24 @@ module Jekyll::Minibundle::Test
|
|
141
141
|
with_site_dir do
|
142
142
|
generate_site(:development)
|
143
143
|
|
144
|
-
|
144
|
+
destination = destination_path(STAMP_DESTINATION_PATH)
|
145
|
+
org_mtime = file_mtime_of(destination)
|
146
|
+
|
147
|
+
assert File.exist?(destination)
|
145
148
|
assert_equal STAMP_DESTINATION_PATH, find_css_path_from_index
|
146
149
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
150
|
+
ensure_file_mtime_changes do
|
151
|
+
find_and_gsub_in_file(
|
152
|
+
source_path('_layouts/default.html'),
|
153
|
+
'{% ministamp _tmp/site.css assets/screen.css',
|
154
|
+
'{% ministamp _tmp/site.css /assets/screen.css'
|
155
|
+
)
|
156
|
+
end
|
152
157
|
|
153
158
|
generate_site(:development, clear_cache: false)
|
154
159
|
|
160
|
+
assert File.exist?(destination)
|
161
|
+
assert_equal org_mtime, file_mtime_of(destination)
|
155
162
|
assert_equal "/#{STAMP_DESTINATION_PATH}", find_css_path_from_index
|
156
163
|
end
|
157
164
|
end
|
@@ -145,18 +145,77 @@ module Jekyll::Minibundle::Test
|
|
145
145
|
with_site_dir do
|
146
146
|
generate_site(:production)
|
147
147
|
|
148
|
-
|
148
|
+
destination = destination_path(STAMP_DESTINATION_FINGERPRINT_PATH)
|
149
|
+
org_mtime = file_mtime_of(destination)
|
150
|
+
|
151
|
+
assert File.exist?(destination)
|
149
152
|
assert_equal STAMP_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
150
153
|
|
154
|
+
ensure_file_mtime_changes do
|
155
|
+
find_and_gsub_in_file(
|
156
|
+
source_path('_layouts/default.html'),
|
157
|
+
'{% ministamp _tmp/site.css assets/screen.css',
|
158
|
+
'{% ministamp _tmp/site.css /assets/screen.css'
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
generate_site(:production, clear_cache: false)
|
163
|
+
|
164
|
+
assert File.exist?(destination)
|
165
|
+
assert_equal org_mtime, file_mtime_of(destination)
|
166
|
+
assert_equal "/#{STAMP_DESTINATION_FINGERPRINT_PATH}", find_css_path_from_index
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_strips_dot_slash_from_relative_destination_path
|
171
|
+
with_site_dir do
|
151
172
|
find_and_gsub_in_file(
|
152
173
|
source_path('_layouts/default.html'),
|
153
174
|
'{% ministamp _tmp/site.css assets/screen.css',
|
154
|
-
'{% ministamp _tmp/site.css
|
175
|
+
'{% ministamp _tmp/site.css screen.css'
|
155
176
|
)
|
156
177
|
|
157
|
-
generate_site(:production
|
178
|
+
generate_site(:production)
|
158
179
|
|
159
|
-
|
180
|
+
destination = destination_path("screen-#{STAMP_FINGERPRINT}.css")
|
181
|
+
org_mtime = file_mtime_of(destination)
|
182
|
+
|
183
|
+
assert File.exist?(destination)
|
184
|
+
assert_equal "screen-#{STAMP_FINGERPRINT}.css", find_css_path_from_index
|
185
|
+
|
186
|
+
ensure_file_mtime_changes do
|
187
|
+
generate_site(:production, clear_cache: false)
|
188
|
+
end
|
189
|
+
|
190
|
+
assert File.exist?(destination)
|
191
|
+
assert_equal org_mtime, file_mtime_of(destination)
|
192
|
+
assert_equal "screen-#{STAMP_FINGERPRINT}.css", find_css_path_from_index
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_strips_dot_slash_from_destination_path
|
197
|
+
with_site_dir do
|
198
|
+
find_and_gsub_in_file(
|
199
|
+
source_path('_layouts/default.html'),
|
200
|
+
'{% ministamp _tmp/site.css assets/screen.css',
|
201
|
+
'{% ministamp _tmp/site.css ./screen.css'
|
202
|
+
)
|
203
|
+
|
204
|
+
generate_site(:production)
|
205
|
+
|
206
|
+
destination = destination_path("screen-#{STAMP_FINGERPRINT}.css")
|
207
|
+
org_mtime = file_mtime_of(destination)
|
208
|
+
|
209
|
+
assert File.exist?(destination)
|
210
|
+
assert_equal "screen-#{STAMP_FINGERPRINT}.css", find_css_path_from_index
|
211
|
+
|
212
|
+
ensure_file_mtime_changes do
|
213
|
+
generate_site(:production, clear_cache: false)
|
214
|
+
end
|
215
|
+
|
216
|
+
assert File.exist?(destination)
|
217
|
+
assert_equal org_mtime, file_mtime_of(destination)
|
218
|
+
assert_equal "screen-#{STAMP_FINGERPRINT}.css", find_css_path_from_index
|
160
219
|
end
|
161
220
|
end
|
162
221
|
|
data/test/support/test_case.rb
CHANGED
@@ -80,11 +80,11 @@ module Jekyll::Minibundle::Test
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
def
|
83
|
+
def make_fake_site(dir)
|
84
84
|
OpenStruct.new(source: dir, static_files: [])
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
87
|
+
def make_real_site
|
88
88
|
config = nil
|
89
89
|
capture_io do
|
90
90
|
config = Jekyll.configuration('source' => Dir.pwd, 'destination' => '_site')
|
@@ -94,7 +94,7 @@ module Jekyll::Minibundle::Test
|
|
94
94
|
|
95
95
|
def with_fake_site(&block)
|
96
96
|
with_site_dir do |dir|
|
97
|
-
block.call(
|
97
|
+
block.call(make_fake_site(dir))
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -163,7 +163,7 @@ module Jekyll::Minibundle::Test
|
|
163
163
|
|
164
164
|
def _generate_site(test_options)
|
165
165
|
AssetFileRegistry.clear_all if test_options.fetch(:clear_cache, true)
|
166
|
-
site =
|
166
|
+
site = make_real_site
|
167
167
|
capture_io { site.process }
|
168
168
|
end
|
169
169
|
end
|
@@ -6,7 +6,7 @@ module Jekyll::Minibundle::Test
|
|
6
6
|
def test_raise_exception_if_bundle_command_fails
|
7
7
|
capture_io do
|
8
8
|
err = assert_raises(RuntimeError) { make_bundle('read _ignore ; false') }
|
9
|
-
assert_equal "Bundling js
|
9
|
+
assert_equal "Bundling assets/site.js failed with exit status 1, command: 'read _ignore ; false'", err.to_s
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -16,7 +16,7 @@ module Jekyll::Minibundle::Test
|
|
16
16
|
assert_raises(RuntimeError) { make_bundle(cmd) }
|
17
17
|
end
|
18
18
|
expected_stderr = <<-END
|
19
|
-
Minibundle: Bundling js
|
19
|
+
Minibundle: Bundling assets/site.js failed with exit status 1, command: '#{cmd}', last 16 bytes of minifier output:
|
20
20
|
Minibundle: line 1\\x07
|
21
21
|
Minibundle: line 2\\xa4
|
22
22
|
END
|
@@ -25,22 +25,29 @@ Minibundle: line 2\\xa4
|
|
25
25
|
|
26
26
|
def test_raise_exception_if_bundle_command_not_found
|
27
27
|
err = assert_raises(RuntimeError) { make_bundle('no-such-jekyll-minibundle-cmd') }
|
28
|
-
assert_equal 'Bundling js
|
28
|
+
assert_equal 'Bundling assets/site.js failed: No such file or directory - no-such-jekyll-minibundle-cmd', err.to_s
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_raise_exception_if_bundle_command_not_configured
|
32
32
|
err = assert_raises(RuntimeError) { make_bundle(nil) }
|
33
|
-
|
33
|
+
expected_errmsg = <<-END
|
34
|
+
Missing minification command for bundling assets/site.js. Specify it in
|
35
|
+
1) minibundle.minifier_commands.js setting in _config.yml,
|
36
|
+
2) $JEKYLL_MINIBUNDLE_CMD_JS environment variable, or
|
37
|
+
3) minifier_cmd setting inside minibundle block.
|
38
|
+
END
|
39
|
+
assert_equal expected_errmsg, err.to_s
|
34
40
|
end
|
35
41
|
|
36
42
|
private
|
37
43
|
|
38
44
|
def make_bundle(minifier_cmd)
|
39
45
|
bundle = AssetBundle.new(
|
40
|
-
type:
|
41
|
-
asset_paths:
|
42
|
-
|
43
|
-
|
46
|
+
type: :js,
|
47
|
+
asset_paths: [site_fixture_path('_assets/scripts/dependency.js')],
|
48
|
+
destination_path: 'assets/site',
|
49
|
+
site_dir: site_fixture_path,
|
50
|
+
minifier_cmd: minifier_cmd
|
44
51
|
)
|
45
52
|
bundle.make_bundle
|
46
53
|
end
|
@@ -5,7 +5,7 @@ module Jekyll::Minibundle::Test
|
|
5
5
|
class AssetFileRegistryTest < TestCase
|
6
6
|
def setup
|
7
7
|
AssetFileRegistry.clear_all
|
8
|
-
@site =
|
8
|
+
@site = make_site
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_register_returns_same_bundle_file_for_same_bundle_config
|
@@ -195,8 +195,8 @@ Two or more ministamp tags with the same destination path 'assets/dest1.css', bu
|
|
195
195
|
AssetFileRegistry.instance_variable_get(:@_files).size
|
196
196
|
end
|
197
197
|
|
198
|
-
def
|
199
|
-
|
198
|
+
def make_site
|
199
|
+
make_fake_site('.')
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end
|
@@ -5,46 +5,34 @@ module Jekyll::Minibundle::Test
|
|
5
5
|
class AssetTagMarkupTest < TestCase
|
6
6
|
def test_escape_attribute_value
|
7
7
|
attributes = {media: 'screen, projection', extra: '">attack<br'}
|
8
|
-
actual = AssetTagMarkup.make_markup(:css, '
|
8
|
+
actual = AssetTagMarkup.make_markup(:css, '/asset.css', attributes)
|
9
9
|
expected = %{<link rel="stylesheet" href="/asset.css" media="screen, projection" extra="">attack<br">}
|
10
10
|
assert_equal expected, actual
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_output_just_attribute_name_for_nil_value
|
14
|
-
actual = AssetTagMarkup.make_markup(:css, '
|
14
|
+
actual = AssetTagMarkup.make_markup(:css, '/asset.css', async: nil)
|
15
15
|
expected = %{<link rel="stylesheet" href="/asset.css" async>}
|
16
16
|
assert_equal expected, actual
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_convert_attribute_value_to_string
|
20
|
-
actual = AssetTagMarkup.make_markup(:css, '
|
20
|
+
actual = AssetTagMarkup.make_markup(:css, '/asset.css', boolean: false)
|
21
21
|
expected = %{<link rel="stylesheet" href="/asset.css" boolean="false">}
|
22
22
|
assert_equal expected, actual
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_output_empty_attribute_value
|
26
|
-
actual = AssetTagMarkup.make_markup(:css, '
|
26
|
+
actual = AssetTagMarkup.make_markup(:css, '/asset.css', empty: '')
|
27
27
|
expected = %{<link rel="stylesheet" href="/asset.css" empty="">}
|
28
28
|
assert_equal expected, actual
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_raise_exception_if_unknown_type
|
32
32
|
err = assert_raises(ArgumentError) do
|
33
|
-
AssetTagMarkup.make_markup(:unknown, '
|
33
|
+
AssetTagMarkup.make_markup(:unknown, '/asset', {})
|
34
34
|
end
|
35
35
|
assert_equal 'Unknown type for generating bundle markup: unknown, /asset', err.to_s
|
36
36
|
end
|
37
|
-
|
38
|
-
def test_join_empty_baseurl_and_path
|
39
|
-
assert_equal %{<link rel="stylesheet" href="asset.css">}, AssetTagMarkup.make_markup(:css, '', 'asset.css', {})
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_join_nonempty_baseurl_and_path
|
43
|
-
assert_equal %{<link rel="stylesheet" href="/root/path/asset.css">}, AssetTagMarkup.make_markup(:css, '/root', 'path/asset.css', {})
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_remove_extra_slash_between_baseurl_and_path
|
47
|
-
assert_equal %{<link rel="stylesheet" href="/asset.css">}, AssetTagMarkup.make_markup(:css, '/', '/asset.css', {})
|
48
|
-
end
|
49
37
|
end
|
50
38
|
end
|