jekyll-minibundle 1.5.1 → 1.6.0

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -6
  3. data/README.md +34 -24
  4. data/Rakefile +19 -14
  5. data/jekyll-minibundle.gemspec +5 -4
  6. data/lib/jekyll/minibundle/asset_bundle.rb +24 -4
  7. data/lib/jekyll/minibundle/asset_file_operations.rb +0 -8
  8. data/lib/jekyll/minibundle/asset_file_properties.rb +26 -8
  9. data/lib/jekyll/minibundle/asset_file_registry.rb +57 -21
  10. data/lib/jekyll/minibundle/asset_tag_markup.rb +13 -4
  11. data/lib/jekyll/minibundle/bundle_file.rb +9 -6
  12. data/lib/jekyll/minibundle/compatibility.rb +11 -1
  13. data/lib/jekyll/minibundle/development_file.rb +6 -0
  14. data/lib/jekyll/minibundle/development_file_collection.rb +3 -16
  15. data/lib/jekyll/minibundle/environment.rb +5 -12
  16. data/lib/jekyll/minibundle/files.rb +18 -0
  17. data/lib/jekyll/minibundle/hashes.rb +20 -0
  18. data/lib/jekyll/minibundle/mini_bundle_block.rb +52 -12
  19. data/lib/jekyll/minibundle/mini_stamp_tag.rb +27 -8
  20. data/lib/jekyll/minibundle/stamp_file.rb +9 -6
  21. data/lib/jekyll/minibundle/version.rb +1 -1
  22. data/test/fixture/site/_bin/with_count +6 -5
  23. data/test/integration/known_caveats_test.rb +89 -0
  24. data/test/integration/minibundle_development_mode_test.rb +171 -26
  25. data/test/integration/minibundle_production_mode_test.rb +234 -42
  26. data/test/integration/ministamp_development_mode_test.rb +145 -0
  27. data/test/integration/{ministamp_test.rb → ministamp_production_mode_test.rb} +72 -23
  28. data/test/integration/static_files_as_asset_sources_test.rb +3 -0
  29. data/test/support/assertions.rb +24 -0
  30. data/test/support/fixture_config.rb +13 -10
  31. data/test/support/static_file_api_config.rb +9 -3
  32. data/test/support/test_case.rb +7 -6
  33. data/test/unit/asset_bundle_test.rb +16 -2
  34. data/test/unit/asset_file_registry_test.rb +117 -14
  35. data/test/unit/asset_tag_markup_test.rb +17 -5
  36. data/test/unit/bundle_file_properties_test.rb +32 -8
  37. data/test/unit/bundle_file_writing_test.rb +10 -11
  38. data/test/unit/development_file_collection_properties_test.rb +47 -15
  39. data/test/unit/environment_test.rb +0 -13
  40. data/test/unit/files_test.rb +46 -0
  41. data/test/unit/hashes_test.rb +41 -0
  42. data/test/unit/mini_bundle_block_test.rb +56 -1
  43. data/test/unit/mini_stamp_tag_test.rb +8 -8
  44. data/test/unit/stamp_file_properties_test.rb +32 -13
  45. data/test/unit/stamp_file_writing_test.rb +1 -5
  46. metadata +38 -16
  47. data/test/unit/development_file_collection_writing_test.rb +0 -43
  48. data/test/unit/jekyll_payload_test.rb +0 -64
@@ -6,12 +6,26 @@ 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 assets failed with exit status 1, command: read _ignore ; false', err.to_s
9
+ assert_equal "Bundling js assets failed with exit status 1, command: 'read _ignore ; false'", err.to_s
10
10
  end
11
11
  end
12
12
 
13
+ def test_log_minifier_stdout_if_bundle_command_fails
14
+ cmd = 'ruby -E ISO-8859-15 -e \'gets; puts "line 1\a\nline\t2\xa4"; abort\''
15
+ _, actual_stderr = capture_io do
16
+ assert_raises(RuntimeError) { make_bundle(cmd) }
17
+ end
18
+ expected_stderr = <<-END
19
+ Minibundle: Bundling js assets failed with exit status 1, command: '#{cmd}', last 16 bytes of minifier output:
20
+ Minibundle: line 1\\x07
21
+ Minibundle: line 2\\xa4
22
+ END
23
+ assert_equal expected_stderr, actual_stderr.gsub(/\e\[\d+m/, '').gsub(/^ +/, '')
24
+ end
25
+
13
26
  def test_raise_exception_if_bundle_command_not_found
14
- assert_raises(Errno::ENOENT) { make_bundle('no-such-jekyll-minibundle-cmd') }
27
+ err = assert_raises(RuntimeError) { make_bundle('no-such-jekyll-minibundle-cmd') }
28
+ assert_equal 'Bundling js assets failed: No such file or directory - no-such-jekyll-minibundle-cmd', err.to_s
15
29
  end
16
30
 
17
31
  def test_raise_exception_if_bundle_command_not_configured
@@ -5,26 +5,130 @@ module Jekyll::Minibundle::Test
5
5
  class AssetFileRegistryTest < TestCase
6
6
  def setup
7
7
  AssetFileRegistry.clear
8
+ @site = new_site
8
9
  end
9
10
 
10
- def test_returns_same_stamp_file_instance_for_same_destination_path
11
- first = AssetFileRegistry.stamp_file(site, '_assets/src1.css', 'assets/dest.css')
12
- second = AssetFileRegistry.stamp_file(site, '_assets/src2.css', 'assets/dest.css')
11
+ def test_register_returns_same_bundle_file_for_same_bundle_configs
12
+ first = AssetFileRegistry.register_bundle_file(@site, bundle_config)
13
+ second = AssetFileRegistry.register_bundle_file(@site, bundle_config)
13
14
  assert_same first, second
14
15
  assert_equal 1, asset_file_registry_size
16
+ assert_contains_only @site.static_files, [first]
15
17
  end
16
18
 
17
- def test_returns_same_bundle_file_instance_for_same_destination_path_and_type
18
- first = AssetFileRegistry.bundle_file(site, bundle_config.merge('assets' => %w{a1 a2}))
19
- second = AssetFileRegistry.bundle_file(site, bundle_config.merge('assets' => %w{b1 b2}))
19
+ def test_register_returns_same_development_file_collection_for_same_bundle_configs
20
+ first = AssetFileRegistry.register_development_file_collection(@site, bundle_config)
21
+ second = AssetFileRegistry.register_development_file_collection(@site, bundle_config)
20
22
  assert_same first, second
21
23
  assert_equal 1, asset_file_registry_size
24
+ assert_contains_only @site.static_files, first.files
22
25
  end
23
26
 
24
- def test_bundle_files_allow_same_path_for_different_types
25
- AssetFileRegistry.bundle_file(site, bundle_config.merge('type' => :css))
26
- AssetFileRegistry.bundle_file(site, bundle_config.merge('type' => :js))
27
+ def test_register_returns_different_bundle_files_for_bundle_configs_with_different_destination_paths
28
+ first = AssetFileRegistry.register_bundle_file(@site, bundle_config.merge('destination_path' => 'assets/dest1'))
29
+ second = AssetFileRegistry.register_bundle_file(@site, bundle_config.merge('destination_path' => 'assets/dest2'))
30
+ refute_same first, second
27
31
  assert_equal 2, asset_file_registry_size
32
+ assert_contains_only @site.static_files, [first, second]
33
+ end
34
+
35
+ def test_register_returns_different_development_file_collections_for_bundle_configs_with_different_destination_paths
36
+ first = AssetFileRegistry.register_development_file_collection(@site, bundle_config.merge('destination_path' => 'assets/dest1'))
37
+ second = AssetFileRegistry.register_development_file_collection(@site, bundle_config.merge('destination_path' => 'assets/dest2'))
38
+ refute_same first, second
39
+ assert_equal 2, asset_file_registry_size
40
+ assert_contains_only @site.static_files, (first.files + second.files)
41
+ end
42
+
43
+ def test_register_returns_different_bundle_files_for_bundle_configs_with_different_types
44
+ first = AssetFileRegistry.register_bundle_file(@site, bundle_config.merge('type' => :css))
45
+ second = AssetFileRegistry.register_bundle_file(@site, bundle_config.merge('type' => :js))
46
+ refute_same first, second
47
+ assert_equal 2, asset_file_registry_size
48
+ assert_contains_only @site.static_files, [first, second]
49
+ end
50
+
51
+ def test_register_returns_different_development_file_collections_for_bundle_configs_with_different_types
52
+ first = AssetFileRegistry.register_development_file_collection(@site, bundle_config.merge('type' => :css))
53
+ second = AssetFileRegistry.register_development_file_collection(@site, bundle_config.merge('type' => :js))
54
+ refute_same first, second
55
+ assert_equal 2, asset_file_registry_size
56
+ assert_contains_only @site.static_files, (first.files + second.files)
57
+ end
58
+
59
+ [
60
+ {description: 'assets', config_diff: {'assets' => %w{b1 b2}}},
61
+ {description: 'source_directory', config_diff: {'source_dir' => '_assets/src2'}}
62
+ ].each do |spec|
63
+ define_method :"test_register_replaces_cached_bundle_file_with_bundle_config_with_different_#{spec.fetch(:description)}" do
64
+ first = AssetFileRegistry.register_bundle_file(@site, bundle_config)
65
+ second = AssetFileRegistry.register_bundle_file(@site, bundle_config.merge(spec[:config_diff]))
66
+ refute_same first, second
67
+ assert_equal 1, asset_file_registry_size
68
+ assert_contains_only @site.static_files, [second]
69
+ end
70
+ end
71
+
72
+ [
73
+ {description: 'assets', config_diff: {'assets' => %w{b1 b2}}},
74
+ {description: 'source_directory', config_diff: {'source_dir' => '_assets/src2'}}
75
+ ].each do |spec|
76
+ define_method :"test_register_replaces_cached_development_file_collection_with_bundle_config_with_different_#{spec.fetch(:description)}" do
77
+ first = AssetFileRegistry.register_development_file_collection(@site, bundle_config)
78
+ second = AssetFileRegistry.register_development_file_collection(@site, bundle_config.merge(spec[:config_diff]))
79
+ refute_same first, second
80
+ assert_equal 1, asset_file_registry_size
81
+ assert_contains_only @site.static_files, second.files
82
+ end
83
+ end
84
+
85
+ [
86
+ {description: 'stamp_file', method: :register_stamp_file},
87
+ {description: 'development_file', method: :register_development_file}
88
+ ].each do |spec|
89
+ define_method :"test_register_returns_same_#{spec.fetch(:description)}_for_same_source_and_destination_paths" do
90
+ first = AssetFileRegistry.send(spec.fetch(:method), @site, '_assets/src1.css', 'assets/dest1.css')
91
+ second = AssetFileRegistry.send(spec.fetch(:method), @site, '_assets/src1.css', 'assets/dest1.css')
92
+ assert_same first, second
93
+ assert_equal 1, asset_file_registry_size
94
+ assert_contains_only @site.static_files, [first]
95
+ end
96
+
97
+ define_method :"test_register_returns_different_#{spec.fetch(:description)}s_for_different_source_and_destination_paths" do
98
+ first = AssetFileRegistry.send(spec.fetch(:method), @site, '_assets/src1.css', 'assets/dest1.css')
99
+ second = AssetFileRegistry.send(spec.fetch(:method), @site, '_assets/src2.css', 'assets/dest2.css')
100
+ refute_same first, second
101
+ assert_equal 2, asset_file_registry_size
102
+ assert_contains_only @site.static_files, [first, second]
103
+ end
104
+
105
+ define_method :"test_register_replaces_cached_#{spec.fetch(:description)}_with_different_source_and_same_destination_paths" do
106
+ first = AssetFileRegistry.send(spec.fetch(:method), @site, '_assets/src1.css', 'assets/dest1.css')
107
+ second = AssetFileRegistry.send(spec.fetch(:method), @site, '_assets/src2.css', 'assets/dest1.css')
108
+ refute_same first, second
109
+ assert_equal 1, asset_file_registry_size
110
+ assert_contains_only @site.static_files, [second]
111
+ end
112
+ end
113
+
114
+ def test_raise_exception_if_registering_stamp_file_with_same_destination_path_as_existing_bundle_file
115
+ file = AssetFileRegistry.register_bundle_file(@site, bundle_config.merge('type' => :css, 'destination_path' => 'assets/dest'))
116
+ err = assert_raises(RuntimeError) do
117
+ AssetFileRegistry.register_stamp_file(@site, '_assets/src1.css', 'assets/dest.css')
118
+ end
119
+ assert_equal 'ministamp tag has same destination path as a minibundle block: assets/dest.css', err.to_s
120
+ assert_equal 1, asset_file_registry_size
121
+ assert_contains_only @site.static_files, [file]
122
+ end
123
+
124
+ def test_raise_exception_if_registering_bundle_file_with_same_destination_path_as_existing_stamp_file
125
+ file = AssetFileRegistry.register_stamp_file(@site, '_assets/src1.css', 'assets/dest.css')
126
+ err = assert_raises(RuntimeError) do
127
+ AssetFileRegistry.register_bundle_file(@site, bundle_config.merge('type' => :css, 'destination_path' => 'assets/dest'))
128
+ end
129
+ assert_equal 'minibundle block has same destination path as a ministamp tag: assets/dest.css', err.to_s
130
+ assert_equal 1, asset_file_registry_size
131
+ assert_contains_only @site.static_files, [file]
28
132
  end
29
133
 
30
134
  private
@@ -32,19 +136,18 @@ module Jekyll::Minibundle::Test
32
136
  def bundle_config
33
137
  {
34
138
  'type' => :css,
35
- 'source_dir' => '_assets/styles',
139
+ 'source_dir' => '_assets/src',
36
140
  'assets' => %w{dependency app},
37
- 'destination_path' => 'assets/site',
38
- 'attributes' => {},
141
+ 'destination_path' => 'assets/dest',
39
142
  'minifier_cmd' => 'unused_minifier_cmd'
40
143
  }
41
144
  end
42
145
 
43
146
  def asset_file_registry_size
44
- AssetFileRegistry.instance_variable_get(:@_instances).size
147
+ AssetFileRegistry.instance_variable_get(:@_files).size
45
148
  end
46
149
 
47
- def site
150
+ def new_site
48
151
  new_fake_site('.')
49
152
  end
50
153
  end
@@ -4,17 +4,29 @@ require 'jekyll/minibundle/asset_tag_markup'
4
4
  module Jekyll::Minibundle::Test
5
5
  class AssetTagMarkupTest < TestCase
6
6
  def test_escapes_attribute_values
7
- attributes = { media: 'screen, projection', extra: '">attack<br' }
8
- actual = AssetTagMarkup.make_markup(:css, '/asset', attributes)
9
- expected = %{<link rel="stylesheet" href="/asset" media="screen, projection" extra="&quot;&gt;attack&lt;br">}
7
+ attributes = {media: 'screen, projection', extra: '">attack<br'}
8
+ actual = AssetTagMarkup.make_markup(:css, '', '/asset.css', attributes)
9
+ expected = %{<link rel="stylesheet" href="/asset.css" media="screen, projection" extra="&quot;&gt;attack&lt;br">}
10
10
  assert_equal expected, actual
11
11
  end
12
12
 
13
13
  def test_raise_exception_if_unknown_type
14
14
  err = assert_raises(ArgumentError) do
15
- AssetTagMarkup.make_markup(:unknown, '/asset', {})
15
+ AssetTagMarkup.make_markup(:unknown, '', '/asset', {})
16
16
  end
17
- assert_equal "Unknown type for generating bundle markup: unknown, /asset", err.to_s
17
+ assert_equal 'Unknown type for generating bundle markup: unknown, /asset', err.to_s
18
+ end
19
+
20
+ def test_joins_empty_baseurl_and_path
21
+ assert_equal %{<link rel="stylesheet" href="asset.css">}, AssetTagMarkup.make_markup(:css, '', 'asset.css', {})
22
+ end
23
+
24
+ def test_joins_nonempty_baseurl_and_path
25
+ assert_equal %{<link rel="stylesheet" href="/root/path/asset.css">}, AssetTagMarkup.make_markup(:css, '/root', 'path/asset.css', {})
26
+ end
27
+
28
+ def test_removes_extra_slash_between_baseurl_and_path
29
+ assert_equal %{<link rel="stylesheet" href="/asset.css">}, AssetTagMarkup.make_markup(:css, '/', '/asset.css', {})
18
30
  end
19
31
  end
20
32
  end
@@ -15,19 +15,44 @@ module Jekyll::Minibundle::Test
15
15
  end
16
16
  end
17
17
 
18
- def test_to_liquid
19
- hash = @results.fetch(:to_liquid)
20
- assert_match(%r{/jekyll-minibundle-.+\.js\z}, hash['path'])
21
- refute_empty hash['modified_time']
22
- assert_equal '.js', hash['extname']
18
+ def test_defaults
19
+ assert_equal({}, @results.fetch(:defaults))
20
+ end
21
+
22
+ def test_destination_rel_dir
23
+ assert_equal 'assets', @results.fetch(:destination_rel_dir)
23
24
  end
24
25
 
25
26
  def test_extname
26
27
  assert_equal '.js', @results.fetch(:extname)
27
28
  end
28
29
 
29
- def test_destination_rel_dir
30
- assert_equal 'assets', @results.fetch(:destination_rel_dir)
30
+ def test_modified_time
31
+ assert_instance_of Time, @results.fetch(:modified_time)
32
+ end
33
+
34
+ def test_mtime
35
+ mtime = @results.fetch(:modified_time)
36
+ assert_equal mtime.to_i, @results.fetch(:mtime)
37
+ end
38
+
39
+ def test_placeholders
40
+ assert_equal({}, @results.fetch(:placeholders))
41
+ end
42
+
43
+ def test_relative_path
44
+ assert_match(%r{/jekyll-minibundle-.+\.js\z}, @results.fetch(:relative_path))
45
+ end
46
+
47
+ def test_to_liquid
48
+ hash = @results.fetch(:to_liquid)
49
+ assert_match(%r{/jekyll-minibundle-.+\.js\z}, hash['path'])
50
+ assert_instance_of Time, hash['modified_time']
51
+ assert_equal '.js', hash['extname']
52
+ end
53
+
54
+ def test_type
55
+ assert_nil @results.fetch(:type)
31
56
  end
32
57
 
33
58
  def test_write?
@@ -42,7 +67,6 @@ module Jekyll::Minibundle::Test
42
67
  'source_dir' => JS_BUNDLE_SOURCE_DIR,
43
68
  'assets' => %w{dependency app},
44
69
  'destination_path' => JS_BUNDLE_DESTINATION_PATH,
45
- 'attributes' => {},
46
70
  'minifier_cmd' => minifier_cmd
47
71
  }
48
72
  end
@@ -11,8 +11,8 @@ module Jekyll::Minibundle::Test
11
11
  bundle_file = BundleFile.new(site, bundle_config(minifier_cmd_to_remove_comments_and_count))
12
12
  source = source_path(JS_BUNDLE_SOURCE_DIR, 'app.js')
13
13
  old_destination = destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH)
14
- org_markup, last_markup = nil
15
- capture_io { org_markup = bundle_file.destination_path_for_markup }
14
+ org_markup_path, last_markup_path = nil
15
+ capture_io { org_markup_path = bundle_file.destination_path_for_markup }
16
16
 
17
17
  assert bundle_file.write('_site')
18
18
 
@@ -20,23 +20,23 @@ module Jekyll::Minibundle::Test
20
20
 
21
21
  assert_equal 1, get_minifier_cmd_count
22
22
 
23
- last_markup = bundle_file.destination_path_for_markup
23
+ last_markup_path = bundle_file.destination_path_for_markup
24
24
  ensure_file_mtime_changes { File.write(source, '(function() {})()') }
25
25
 
26
26
  # preserve fingerprint and content seen in last markup phase
27
27
  refute bundle_file.write('_site')
28
- assert_equal org_markup, last_markup
28
+ assert_equal org_markup_path, last_markup_path
29
29
  assert_equal org_mtime, mtime_of(old_destination)
30
30
  assert_equal 1, get_minifier_cmd_count
31
31
 
32
- capture_io { last_markup = bundle_file.destination_path_for_markup }
32
+ capture_io { last_markup_path = bundle_file.destination_path_for_markup }
33
33
 
34
34
  assert bundle_file.write('_site')
35
35
 
36
36
  new_destination = destination_path('assets/site-375a0b430b0c5555d0edd2205d26c04d.js')
37
37
 
38
38
  # see updated fingerprint in the next round
39
- refute_equal org_markup, last_markup
39
+ refute_equal org_markup_path, last_markup_path
40
40
  assert_operator mtime_of(new_destination), :>, org_mtime
41
41
  assert_equal 2, get_minifier_cmd_count
42
42
  end
@@ -47,8 +47,8 @@ module Jekyll::Minibundle::Test
47
47
  bundle_file = BundleFile.new(site, bundle_config(minifier_cmd_to_remove_comments_and_count))
48
48
  source = source_path(JS_BUNDLE_SOURCE_DIR, 'app.js')
49
49
  destination = destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH)
50
- org_markup, last_markup = nil
51
- capture_io { org_markup = bundle_file.destination_path_for_markup }
50
+ org_markup_path, last_markup_path = nil
51
+ capture_io { org_markup_path = bundle_file.destination_path_for_markup }
52
52
  bundle_file.destination_path_for_markup
53
53
 
54
54
  assert bundle_file.write('_site')
@@ -58,11 +58,11 @@ module Jekyll::Minibundle::Test
58
58
  assert_equal 1, get_minifier_cmd_count
59
59
 
60
60
  ensure_file_mtime_changes { FileUtils.touch(source) }
61
- capture_io { last_markup = bundle_file.destination_path_for_markup }
61
+ capture_io { last_markup_path = bundle_file.destination_path_for_markup }
62
62
  bundle_file.destination_path_for_markup
63
63
 
64
64
  assert bundle_file.write('_site')
65
- assert_equal org_markup, last_markup
65
+ assert_equal org_markup_path, last_markup_path
66
66
  assert_operator mtime_of(destination), :>, org_mtime
67
67
  assert_equal 2, get_minifier_cmd_count
68
68
  end
@@ -92,7 +92,6 @@ module Jekyll::Minibundle::Test
92
92
  'source_dir' => JS_BUNDLE_SOURCE_DIR,
93
93
  'assets' => %w{dependency app},
94
94
  'destination_path' => JS_BUNDLE_DESTINATION_PATH,
95
- 'attributes' => {},
96
95
  'minifier_cmd' => minifier_cmd
97
96
  }
98
97
  end
@@ -18,26 +18,59 @@ module Jekyll::Minibundle::Test
18
18
  end
19
19
  end
20
20
 
21
+ def test_defaults
22
+ assert_equal({}, @results.fetch(:dependency).fetch(:defaults))
23
+ assert_equal({}, @results.fetch(:app).fetch(:defaults))
24
+ end
25
+
26
+ def test_destination_rel_dir
27
+ assert_equal 'assets/site', @results.fetch(:dependency).fetch(:destination_rel_dir)
28
+ assert_equal 'assets/site', @results.fetch(:app).fetch(:destination_rel_dir)
29
+ end
30
+
31
+ def test_extname
32
+ assert_equal '.js', @results.fetch(:dependency).fetch(:extname)
33
+ assert_equal '.js', @results.fetch(:app).fetch(:extname)
34
+ end
35
+
36
+ def test_modified_time
37
+ assert_instance_of Time, @results.fetch(:dependency).fetch(:modified_time)
38
+ assert_instance_of Time, @results.fetch(:app).fetch(:modified_time)
39
+ end
40
+
41
+ def test_mtime
42
+ dep_mtime = @results.fetch(:dependency).fetch(:modified_time)
43
+ assert_equal dep_mtime.to_i, @results.fetch(:dependency).fetch(:mtime)
44
+
45
+ app_mtime = @results.fetch(:app).fetch(:modified_time)
46
+ assert_equal app_mtime.to_i, @results.fetch(:app).fetch(:mtime)
47
+ end
48
+
49
+ def test_placeholders
50
+ assert_equal({}, @results.fetch(:dependency).fetch(:placeholders))
51
+ assert_equal({}, @results.fetch(:app).fetch(:placeholders))
52
+ end
53
+
54
+ def test_relative_path
55
+ assert_equal "/#{JS_BUNDLE_SOURCE_DIR}/dependency.js", @results.fetch(:dependency).fetch(:relative_path)
56
+ assert_equal "/#{JS_BUNDLE_SOURCE_DIR}/app.js", @results.fetch(:app).fetch(:relative_path)
57
+ end
58
+
21
59
  def test_to_liquid
22
60
  hash = @results.fetch(:dependency).fetch(:to_liquid)
23
61
  assert_equal "/#{JS_BUNDLE_SOURCE_DIR}/dependency.js", hash['path']
24
- refute_empty hash['modified_time']
62
+ assert_instance_of Time, hash['modified_time']
25
63
  assert_equal '.js', hash['extname']
26
64
 
27
65
  hash = @results.fetch(:app).fetch(:to_liquid)
28
66
  assert_equal "/#{JS_BUNDLE_SOURCE_DIR}/app.js", hash['path']
29
- refute_empty hash['modified_time']
67
+ assert_instance_of Time, hash['modified_time']
30
68
  assert_equal '.js', hash['extname']
31
69
  end
32
70
 
33
- def test_extname
34
- assert_equal '.js', @results.fetch(:dependency).fetch(:extname)
35
- assert_equal '.js', @results.fetch(:app).fetch(:extname)
36
- end
37
-
38
- def test_destination_rel_dir
39
- assert_equal 'assets/site', @results.fetch(:dependency).fetch(:destination_rel_dir)
40
- assert_equal 'assets/site', @results.fetch(:app).fetch(:destination_rel_dir)
71
+ def test_type
72
+ assert_nil @results.fetch(:dependency).fetch(:type)
73
+ assert_nil @results.fetch(:app).fetch(:type)
41
74
  end
42
75
 
43
76
  def test_write?
@@ -49,11 +82,10 @@ module Jekyll::Minibundle::Test
49
82
 
50
83
  def bundle_config
51
84
  {
52
- 'type' => :js,
53
- 'source_dir' => JS_BUNDLE_SOURCE_DIR,
54
- 'assets' => %w{dependency app},
55
- 'destination_path' => JS_BUNDLE_DESTINATION_PATH,
56
- 'attributes' => {}
85
+ 'type' => :js,
86
+ 'source_dir' => JS_BUNDLE_SOURCE_DIR,
87
+ 'assets' => %w{dependency app},
88
+ 'destination_path' => JS_BUNDLE_DESTINATION_PATH
57
89
  }
58
90
  end
59
91
  end
@@ -3,19 +3,6 @@ require 'jekyll/minibundle/environment'
3
3
 
4
4
  module Jekyll::Minibundle::Test
5
5
  class EnvironmentTest < TestCase
6
- def test_traverse_keys_returns_value_when_found
7
- assert_equal 1, Environment.traverse_keys({top: {middle: {leaf: 1}}}, [:top, :middle, :leaf])
8
- assert_equal({leaf: 1}, Environment.traverse_keys({top: {middle: {leaf: 1}}}, [:top, :middle]))
9
- assert_equal 1, Environment.traverse_keys({top: [{}, {leaf: 1}]}, [:top, 1, :leaf])
10
- end
11
-
12
- def test_traverse_keys_returns_nil_when_not_found
13
- assert_nil Environment.traverse_keys({}, [:top, :no_such_leaf])
14
- assert_nil Environment.traverse_keys({top: {}}, [:top, :no_such_leaf])
15
- assert_nil Environment.traverse_keys({top: {leaf: 1}}, [:top, :no_such_leaf])
16
- assert_nil Environment.traverse_keys({top: []}, [:top, 0])
17
- end
18
-
19
6
  def test_find_site_config_returns_value_when_found
20
7
  assert_equal 1, Environment.find_site_config(new_site(top: {leaf: 1}), [:top, :leaf], Integer)
21
8
  end