jekyll-minibundle 3.0.0 → 4.0.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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -66
  3. data/README.md +117 -101
  4. data/Rakefile +8 -26
  5. data/jekyll-minibundle.gemspec +5 -11
  6. data/lib/jekyll/minibundle/asset_bundle.rb +1 -1
  7. data/lib/jekyll/minibundle/asset_file_drop.rb +1 -3
  8. data/lib/jekyll/minibundle/asset_file_registry.rb +2 -2
  9. data/lib/jekyll/minibundle/asset_tag_markup.rb +1 -1
  10. data/lib/jekyll/minibundle/bundle_file.rb +3 -0
  11. data/lib/jekyll/minibundle/development_file.rb +2 -0
  12. data/lib/jekyll/minibundle/hashes.rb +1 -3
  13. data/lib/jekyll/minibundle/stamp_file.rb +3 -0
  14. data/lib/jekyll/minibundle/variable_template.rb +3 -1
  15. data/lib/jekyll/minibundle/variable_template_registry.rb +2 -2
  16. data/lib/jekyll/minibundle/version.rb +1 -1
  17. metadata +8 -184
  18. data/test/fixture/site/_assets/scripts/app.js +0 -5
  19. data/test/fixture/site/_assets/scripts/dependency.js +0 -4
  20. data/test/fixture/site/_assets/styles/common.css +0 -2
  21. data/test/fixture/site/_assets/styles/reset.css +0 -2
  22. data/test/fixture/site/_bin/remove_comments +0 -4
  23. data/test/fixture/site/_bin/with_count +0 -15
  24. data/test/fixture/site/_config.yml +0 -3
  25. data/test/fixture/site/_layouts/default.html +0 -29
  26. data/test/fixture/site/_tmp/site.css +0 -3
  27. data/test/fixture/site/about.html +0 -4
  28. data/test/fixture/site/assets/site.css +0 -2
  29. data/test/fixture/site/index.html +0 -4
  30. data/test/integration/minibundle_development_mode_test.rb +0 -554
  31. data/test/integration/minibundle_production_mode_test.rb +0 -900
  32. data/test/integration/ministamp_development_mode_test.rb +0 -235
  33. data/test/integration/ministamp_production_mode_test.rb +0 -342
  34. data/test/integration/static_files_as_asset_sources_test.rb +0 -75
  35. data/test/support/assertions.rb +0 -26
  36. data/test/support/fixture_config.rb +0 -20
  37. data/test/support/static_file_config.rb +0 -23
  38. data/test/support/test_case.rb +0 -175
  39. data/test/unit/asset_bundle_test.rb +0 -57
  40. data/test/unit/asset_file_drop_test.rb +0 -66
  41. data/test/unit/asset_file_registry_test.rb +0 -237
  42. data/test/unit/asset_tag_markup_test.rb +0 -46
  43. data/test/unit/bundle_file_properties_test.rb +0 -108
  44. data/test/unit/bundle_file_writing_test.rb +0 -155
  45. data/test/unit/development_file_properties_test.rb +0 -97
  46. data/test/unit/development_file_writing_test.rb +0 -50
  47. data/test/unit/environment_test.rb +0 -29
  48. data/test/unit/files_test.rb +0 -61
  49. data/test/unit/hashes_test.rb +0 -43
  50. data/test/unit/jekyll_static_file_api_test.rb +0 -172
  51. data/test/unit/mini_bundle_block_test.rb +0 -125
  52. data/test/unit/mini_stamp_tag_test.rb +0 -64
  53. data/test/unit/stamp_file_properties_test.rb +0 -98
  54. data/test/unit/stamp_file_writing_test.rb +0 -130
  55. data/test/unit/variable_template_test.rb +0 -121
@@ -1,172 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../support/test_case'
4
- require_relative '../support/static_file_config'
5
- require 'jekyll/minibundle/development_file'
6
- require 'jekyll/minibundle/bundle_file'
7
- require 'jekyll/minibundle/stamp_file'
8
-
9
- module Jekyll::Minibundle::Test
10
- class JekyllStaticFileAPITest < TestCase
11
- IGNORED_STATIC_FILE_METHODS = %i[cleaned_relative_path].freeze
12
-
13
- include StaticFileConfig
14
-
15
- def test_development_file_has_most_static_file_methods
16
- assert_empty(missing_static_file_methods(DevelopmentFile))
17
- end
18
-
19
- def test_bundle_file_has_most_static_file_methods
20
- assert_empty(missing_static_file_methods(BundleFile))
21
- end
22
-
23
- def test_stamp_file_has_most_static_file_methods
24
- assert_empty(missing_static_file_methods(StampFile))
25
- end
26
-
27
- def test_development_file_properties_has_similar_return_types_to_static_file_properties
28
- with_real_site do |site|
29
- FileUtils.touch('static.txt')
30
- FileUtils.touch('dev.js')
31
-
32
- return_type_diff = diff_non_nil_response_types_of_static_file_properties(
33
- make_static_file(site, 'static.txt'),
34
- make_development_file(site, 'dev.js')
35
- )
36
-
37
- assert_empty(return_type_diff)
38
- end
39
- end
40
-
41
- def test_bundle_file_properties_has_similar_return_types_to_static_file_properties
42
- with_real_site do |site|
43
- FileUtils.touch('static.txt')
44
- FileUtils.touch('dependency.js')
45
- FileUtils.touch('app.js')
46
-
47
- return_type_diff = diff_non_nil_response_types_of_static_file_properties(
48
- make_static_file(site, 'static.txt'),
49
- make_bundle_file(site, %w[dependency app])
50
- )
51
-
52
- assert_empty(return_type_diff)
53
- end
54
- end
55
-
56
- def test_stamp_file_properties_has_similar_return_types_to_static_file_properties
57
- with_real_site do |site|
58
- FileUtils.touch('static.txt')
59
- FileUtils.touch('stamp.js')
60
-
61
- return_type_diff = diff_non_nil_response_types_of_static_file_properties(
62
- make_static_file(site, 'static.txt'),
63
- make_stamp_file(site, 'stamp.js')
64
- )
65
-
66
- assert_empty(return_type_diff)
67
- end
68
- end
69
-
70
- def test_development_file_has_same_to_liquid_hash_keys_as_static_file
71
- with_real_site do |site|
72
- FileUtils.touch('static.txt')
73
- FileUtils.touch('dev.js')
74
-
75
- expected_keys = make_static_file(site, 'static.txt').to_liquid.keys.sort
76
- actual_keys = make_development_file(site, 'dev.js').to_liquid.keys.sort
77
-
78
- assert_equal(expected_keys, actual_keys)
79
- end
80
- end
81
-
82
- def test_bundle_file_has_same_to_liquid_hash_keys_as_static_file
83
- with_real_site do |site|
84
- FileUtils.touch('static.txt')
85
- FileUtils.touch('dependency.js')
86
- FileUtils.touch('app.js')
87
-
88
- expected_keys = make_static_file(site, 'static.txt').to_liquid.keys.sort
89
- actual_keys = make_bundle_file(site, %w[dependency app]).to_liquid.keys.sort
90
-
91
- assert_equal(expected_keys, actual_keys)
92
- end
93
- end
94
-
95
- def test_stamp_file_has_same_to_liquid_hash_keys_as_static_file
96
- with_real_site do |site|
97
- FileUtils.touch('static.txt')
98
- FileUtils.touch('stamp.js')
99
-
100
- expected_keys = make_static_file(site, 'static.txt').to_liquid.keys.sort
101
- actual_keys = make_stamp_file(site, 'stamp.js').to_liquid.keys.sort
102
-
103
- assert_equal(expected_keys, actual_keys)
104
- end
105
- end
106
-
107
- private
108
-
109
- def missing_static_file_methods(clazz)
110
- Jekyll::StaticFile.public_instance_methods - IGNORED_STATIC_FILE_METHODS - clazz.public_instance_methods
111
- end
112
-
113
- def response_types_of_methods(file, methods)
114
- methods.each_with_object({}) do |method_name, acc|
115
- acc[method_name] =
116
- begin
117
- value = file.send(method_name)
118
- {returned_type: value.class}
119
- rescue StandardError => e
120
- {raised: e}
121
- end
122
- end
123
- end
124
-
125
- def diff_non_nil_response_types_of_static_file_properties(file_master, file_conforming)
126
- methods = STATIC_FILE_PROPERTIES - [:to_liquid]
127
-
128
- master_response_types = response_types_of_methods(file_master, methods)
129
- conforming_response_types = response_types_of_methods(file_conforming, methods)
130
-
131
- master_to_compare = master_response_types.select do |_, value|
132
- value.key?(:returned_type) && value.fetch(:returned_type) != NilClass
133
- end
134
-
135
- master_to_compare.to_a - conforming_response_types.to_a
136
- end
137
-
138
- def with_real_site(&block)
139
- with_site_dir do |dir|
140
- block.call(make_real_site(dir))
141
- end
142
- end
143
-
144
- def make_static_file(site, path)
145
- ::Jekyll::StaticFile.new(
146
- site,
147
- site.source,
148
- "/#{File.dirname(path)}",
149
- File.basename(path)
150
- )
151
- end
152
-
153
- def make_development_file(site, filename)
154
- DevelopmentFile.new(site, filename, filename)
155
- end
156
-
157
- def make_bundle_file(site, assets)
158
- BundleFile.new(
159
- site,
160
- 'type' => :js,
161
- 'source_dir' => '',
162
- 'assets' => assets,
163
- 'destination_path' => 'bundle.js',
164
- 'minifier_cmd' => 'false'
165
- )
166
- end
167
-
168
- def make_stamp_file(site, filename)
169
- StampFile.new(site, filename, filename)
170
- end
171
- end
172
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../support/test_case'
4
- require_relative '../support/fixture_config'
5
- require 'jekyll/minibundle/mini_bundle_block'
6
-
7
- module Jekyll::Minibundle::Test
8
- class MiniBundleBlockTest < TestCase
9
- include FixtureConfig
10
-
11
- def setup
12
- AssetFileRegistry.clear_all
13
- end
14
-
15
- def test_raise_exception_if_no_type_argument
16
- err = assert_raises(ArgumentError) do
17
- Liquid::Template.parse('{% minibundle %} {% endminibundle %}')
18
- end
19
- assert_equal("Missing asset type for minibundle block; pass value such as 'css' or 'js' as the argument", err.to_s)
20
- end
21
-
22
- def test_raise_exception_if_missing_block_contents
23
- err = assert_raises(ArgumentError) do
24
- render_template(<<~LIQUID)
25
- {% minibundle css %}
26
-
27
- {% endminibundle %}
28
- LIQUID
29
- end
30
- assert_equal('Missing configuration for minibundle block; pass configuration in YAML syntax', err.to_s)
31
- end
32
-
33
- def test_raise_exception_if_invalid_block_contents_syntax
34
- err = assert_raises(ArgumentError) do
35
- render_template(<<~LIQUID)
36
- {% minibundle css %}
37
- }
38
- {% endminibundle %}
39
- LIQUID
40
- end
41
- expected =
42
- 'Failed parsing minibundle block contents syntax as YAML: "}". ' \
43
- 'Cause: (<unknown>): did not find expected node content while parsing a block node at line 2 column 1'
44
- assert_equal(expected, err.to_s)
45
- end
46
-
47
- def test_raise_exception_if_unsupported_block_contents_type
48
- err = assert_raises(ArgumentError) do
49
- render_template(<<~LIQUID)
50
- {% minibundle css %}
51
- str
52
- {% endminibundle %}
53
- LIQUID
54
- end
55
- assert_equal("Unsupported minibundle block contents type (String), only Hash is supported: \nstr\n", err.to_s)
56
- end
57
-
58
- [
59
- {
60
- description: 'nil_baseurl_results_in_asset_url_without_baseurl',
61
- baseurl_config: 'baseurl:',
62
- expected_asset_url: CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH
63
- },
64
- {
65
- description: 'empty_baseurl_results_in_asset_url_without_baseurl',
66
- baseurl_config: "baseurl: ''",
67
- expected_asset_url: CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH
68
- },
69
- {
70
- description: 'slash_baseurl_results_in_asset_url_with_baseurl',
71
- baseurl_config: 'baseurl: /',
72
- expected_asset_url: "/#{CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH}"
73
- },
74
- {
75
- description: 'dot_baseurl_results_in_asset_url_without_baseurl',
76
- baseurl_config: 'baseurl: .',
77
- expected_asset_url: CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH
78
- },
79
- {
80
- description: 'dot_slash_baseurl_results_in_asset_url_without_baseurl',
81
- baseurl_config: 'baseurl: ./',
82
- expected_asset_url: CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH
83
- },
84
- {
85
- description: 'slash_root_baseurl_results_in_asset_url_with_baseurl',
86
- baseurl_config: 'baseurl: /root',
87
- expected_asset_url: "/root/#{CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH}"
88
- },
89
- {
90
- description: 'slash_root_slash_baseurl_results_in_asset_url_with_baseurl',
91
- baseurl_config: 'baseurl: /root/',
92
- expected_asset_url: "/root/#{CSS_BUNDLE_DESTINATION_FINGERPRINT_PATH}"
93
- }
94
- ].each do |spec|
95
- define_method :"test_normalizing_baseurl_with_#{spec.fetch(:description)}" do
96
- actual_output = render_template(<<~LIQUID)
97
- {% minibundle css %}
98
- source_dir: _assets/styles
99
- destination_path: assets/site
100
- #{spec.fetch(:baseurl_config)}
101
- assets:
102
- - reset
103
- - common
104
- minifier_cmd: #{minifier_cmd_to_remove_comments}
105
- {% endminibundle %}
106
- LIQUID
107
-
108
- expected_output = %(<link rel="stylesheet" href="#{spec.fetch(:expected_asset_url)}">\n)
109
-
110
- assert_equal(expected_output, actual_output)
111
- end
112
- end
113
-
114
- private
115
-
116
- def render_template(template)
117
- compiled = Liquid::Template.parse(template)
118
- rendered = nil
119
- capture_io do
120
- rendered = compiled.render!({}, registers: {site: make_fake_site(site_fixture_path)})
121
- end
122
- rendered
123
- end
124
- end
125
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../support/test_case'
4
- require_relative '../support/fixture_config'
5
- require 'jekyll/minibundle/mini_stamp_tag'
6
-
7
- module Jekyll::Minibundle::Test
8
- class MiniStampTagTest < TestCase
9
- include FixtureConfig
10
-
11
- def test_raise_exception_if_argument_is_missing
12
- err = assert_raises(ArgumentError) do
13
- Liquid::Template.parse('{% ministamp %}')
14
- end
15
- assert_equal('Missing asset source and destination paths for ministamp tag; specify value such as "_assets/source.css assets/destination.css" as the argument', err.to_s)
16
- end
17
-
18
- def test_raise_exception_if_asset_destination_is_missing_in_string_argument_type
19
- err = assert_raises(ArgumentError) do
20
- Liquid::Template.parse('{% ministamp /_assets/site.css %}')
21
- end
22
- assert_equal('Missing asset destination path for ministamp tag; specify value such as "assets/destination.css" after asset source path argument, separated with a space', err.to_s)
23
- end
24
-
25
- def test_ignores_arguments_after_asset_destination_in_string_argument_type
26
- AssetFileRegistry.clear_all
27
- output = Liquid::Template
28
- .parse("{% ministamp #{STAMP_SOURCE_PATH} #{STAMP_DESTINATION_PATH} rest %}")
29
- .render({}, registers: {site: make_fake_site(site_fixture_path)})
30
- assert_equal(STAMP_DESTINATION_FINGERPRINT_PATH, output)
31
- end
32
-
33
- def test_raise_exception_if_invalid_arguments_syntax
34
- err = assert_raises(ArgumentError) do
35
- Liquid::Template.parse('{% ministamp source_path: src, destination_path: dst %}')
36
- end
37
- expected =
38
- 'Failed parsing ministamp tag argument syntax as YAML: "source_path: src, destination_path: dst". ' \
39
- 'Cause: (<unknown>): mapping values are not allowed in this context at line 1 column 35'
40
- assert_equal(expected, err.to_s)
41
- end
42
-
43
- def test_raise_exception_if_unsupported_argument_type
44
- err = assert_raises(ArgumentError) do
45
- Liquid::Template.parse("{% ministamp ['source_path', 'src', 'destination_path', 'dst'] %}")
46
- end
47
- assert_equal("Unsupported ministamp tag argument type (Array), only String and Hash are supported: ['source_path', 'src', 'destination_path', 'dst']", err.to_s)
48
- end
49
-
50
- def test_raise_exception_if_asset_source_is_missing_in_hash_argument_type
51
- err = assert_raises(ArgumentError) do
52
- Liquid::Template.parse('{% ministamp {} %}')
53
- end
54
- assert_equal('Missing asset source path for ministamp tag; specify Hash entry such as "source_path: _assets/site.css"', err.to_s)
55
- end
56
-
57
- def test_raise_exception_if_asset_destination_is_missing_in_hash_argument_type
58
- err = assert_raises(ArgumentError) do
59
- Liquid::Template.parse('{% ministamp { source_path: src } %}')
60
- end
61
- assert_equal('Missing asset destination path for ministamp tag; specify Hash entry such as "destination_path: assets/site.css"', err.to_s)
62
- end
63
- end
64
- end
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../support/test_case'
4
- require_relative '../support/fixture_config'
5
- require_relative '../support/static_file_config'
6
- require 'jekyll/minibundle/stamp_file'
7
-
8
- module Jekyll::Minibundle::Test
9
- class StampFilePropertiesTest < TestCase
10
- include FixtureConfig
11
- include StaticFileConfig
12
-
13
- def setup
14
- @@results ||= with_stamp_file do |file|
15
- get_send_results(file, STATIC_FILE_PROPERTIES)
16
- end
17
- end
18
-
19
- def test_basename
20
- assert_equal("screen-#{STAMP_FINGERPRINT}", @@results.fetch(:basename))
21
- end
22
-
23
- def test_data
24
- assert_equal({}, @@results.fetch(:data))
25
- end
26
-
27
- def test_defaults
28
- assert_equal({}, @@results.fetch(:defaults))
29
- end
30
-
31
- def test_destination_rel_dir
32
- assert_equal('/assets', @@results.fetch(:destination_rel_dir))
33
- end
34
-
35
- def test_extname
36
- assert_equal('.css', @@results.fetch(:extname))
37
- end
38
-
39
- def test_modified_time
40
- assert_instance_of(Time, @@results.fetch(:modified_time))
41
- end
42
-
43
- def test_mtime
44
- mtime = @@results.fetch(:modified_time)
45
- assert_equal(mtime.to_i, @@results.fetch(:mtime))
46
- end
47
-
48
- def test_name
49
- assert_equal("screen-#{STAMP_FINGERPRINT}.css", @@results.fetch(:name))
50
- end
51
-
52
- def test_path
53
- assert_match(%r{\A/.+/#{STAMP_SOURCE_PATH}\z}, @@results.fetch(:path))
54
- end
55
-
56
- def test_placeholders
57
- assert_equal({}, @@results.fetch(:placeholders))
58
- end
59
-
60
- def test_relative_path
61
- assert_equal("/#{STAMP_SOURCE_PATH}", @@results.fetch(:relative_path))
62
- end
63
-
64
- def test_to_liquid
65
- with_stamp_file do |file|
66
- drop = file.to_liquid
67
- assert_equal("screen-#{STAMP_FINGERPRINT}.css", drop.name)
68
- assert_equal('.css', drop.extname)
69
- assert_equal("screen-#{STAMP_FINGERPRINT}", drop.basename)
70
- assert_instance_of(Time, drop.modified_time)
71
- assert_equal("/#{STAMP_SOURCE_PATH}", drop.path)
72
- assert_nil(drop.collection)
73
- end
74
- end
75
-
76
- def test_type
77
- assert_nil(@@results.fetch(:type))
78
- end
79
-
80
- def test_url
81
- assert_equal(STAMP_DESTINATION_FINGERPRINT_PATH, @@results.fetch(:url))
82
- end
83
-
84
- def test_write?
85
- assert(@@results.fetch(:write?))
86
- end
87
-
88
- private
89
-
90
- def with_stamp_file(&block)
91
- with_fake_site do |site|
92
- file = StampFile.new(site, STAMP_SOURCE_PATH, STAMP_DESTINATION_PATH)
93
- file.destination_path_for_markup
94
- block.call(file)
95
- end
96
- end
97
- end
98
- end
@@ -1,130 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../support/test_case'
4
- require_relative '../support/fixture_config'
5
- require 'jekyll/minibundle/stamp_file'
6
-
7
- module Jekyll::Minibundle::Test
8
- class StampFileWritingTest < TestCase
9
- include FixtureConfig
10
-
11
- def test_raise_error_if_source_file_does_not_exist
12
- err = assert_raises(ArgumentError) do
13
- with_fake_site do |site|
14
- StampFile.new(site, '_tmp', STAMP_DESTINATION_PATH)
15
- end
16
- end
17
- assert_match(%r{\AStamp source file does not exist: .+/_tmp\z}, err.to_s)
18
- end
19
-
20
- def test_calling_destination_path_for_markup_determines_fingerprint_and_destination_write
21
- with_fake_site do |site|
22
- stamp_file = make_stamp_file(site)
23
- source = source_path(STAMP_SOURCE_PATH)
24
- old_destination = destination_path(STAMP_DESTINATION_FINGERPRINT_PATH)
25
-
26
- # the call to destination_path_for_markup determines the
27
- # fingerprint
28
-
29
- org_markup_path = stamp_file.destination_path_for_markup
30
-
31
- assert(write_file(stamp_file))
32
-
33
- org_mtime = file_mtime_of(old_destination)
34
-
35
- last_markup_path = stamp_file.destination_path_for_markup
36
-
37
- assert_equal(org_markup_path, last_markup_path)
38
-
39
- # change content, but don't call destination_path_for_markup yet
40
-
41
- ensure_file_mtime_changes { File.write(source, 'h1 {}') }
42
-
43
- # preserve content's fingerprint
44
-
45
- refute(write_file(stamp_file))
46
-
47
- assert_equal(org_markup_path, last_markup_path)
48
- assert_equal(org_mtime, file_mtime_of(old_destination))
49
- assert_equal(File.read(site_fixture_path(STAMP_SOURCE_PATH)), File.read(old_destination))
50
-
51
- # see content's fingerprint to update after calling
52
- # destination_path_for_markup
53
-
54
- last_markup_path = stamp_file.destination_path_for_markup
55
-
56
- refute_equal org_markup_path, last_markup_path
57
-
58
- assert(write_file(stamp_file))
59
-
60
- new_destination = destination_path('assets/screen-0f5dbd1e527a2bee267e85007b08d2a5.css')
61
-
62
- assert_operator(file_mtime_of(new_destination), :>, org_mtime)
63
- assert_equal(File.read(source), File.read(new_destination))
64
- end
65
- end
66
-
67
- def test_many_consecutive_destination_path_for_markup_calls_trigger_one_destination_write
68
- with_fake_site do |site|
69
- stamp_file = make_stamp_file(site)
70
- source = source_path(STAMP_SOURCE_PATH)
71
- destination = destination_path(STAMP_DESTINATION_FINGERPRINT_PATH)
72
- org_markup = stamp_file.destination_path_for_markup
73
- stamp_file.destination_path_for_markup
74
-
75
- assert(write_file(stamp_file))
76
-
77
- org_mtime = file_mtime_of(destination)
78
- ensure_file_mtime_changes { FileUtils.touch(source) }
79
- last_markup = stamp_file.destination_path_for_markup
80
- stamp_file.destination_path_for_markup
81
-
82
- assert(write_file(stamp_file))
83
- assert_equal(org_markup, last_markup)
84
- assert_operator(file_mtime_of(destination), :>, org_mtime)
85
- assert_equal(File.read(source), File.read(destination))
86
- end
87
- end
88
-
89
- def test_calling_write_before_destination_path_for_markup_has_no_effect
90
- with_fake_site do |site|
91
- stamp_file = make_stamp_file(site)
92
-
93
- refute(write_file(stamp_file))
94
- assert_empty(Dir[destination_path('assets/*.css')])
95
-
96
- stamp_file.destination_path_for_markup
97
-
98
- assert(write_file(stamp_file))
99
- assert(File.file?(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH)))
100
- end
101
- end
102
-
103
- def test_modified_property_determines_if_write_would_succeed
104
- with_fake_site do |site|
105
- stamp_file = make_stamp_file(site)
106
-
107
- refute(stamp_file.modified?)
108
- refute(write_file(stamp_file))
109
-
110
- stamp_file.destination_path_for_markup
111
-
112
- assert(stamp_file.modified?)
113
- assert(write_file(stamp_file))
114
-
115
- refute(stamp_file.modified?)
116
- refute(write_file(stamp_file))
117
- end
118
- end
119
-
120
- private
121
-
122
- def make_stamp_file(site)
123
- StampFile.new(site, STAMP_SOURCE_PATH, STAMP_DESTINATION_PATH)
124
- end
125
-
126
- def write_file(file)
127
- file.write(File.join(Dir.pwd, '_site'))
128
- end
129
- end
130
- end