nanoc 4.4.5 → 4.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -2
  3. data/Gemfile.lock +37 -18
  4. data/NEWS.md +6 -0
  5. data/Rakefile +8 -20
  6. data/lib/nanoc/base/entities/code_snippet.rb +0 -2
  7. data/lib/nanoc/base/entities/item_rep.rb +4 -22
  8. data/lib/nanoc/base/entities/processing_actions/snapshot.rb +9 -7
  9. data/lib/nanoc/base/entities/rule_memory.rb +15 -7
  10. data/lib/nanoc/base/entities/snapshot_def.rb +2 -8
  11. data/lib/nanoc/base/repos/store.rb +2 -28
  12. data/lib/nanoc/base/services/checksummer.rb +9 -10
  13. data/lib/nanoc/base/services/compiler.rb +14 -16
  14. data/lib/nanoc/base/services/executor.rb +2 -13
  15. data/lib/nanoc/base/views/mixins/with_reps_view_mixin.rb +1 -1
  16. data/lib/nanoc/checking/checks/external_links.rb +2 -1
  17. data/lib/nanoc/cli/commands/compile.rb +8 -14
  18. data/lib/nanoc/extra/parallel_collection.rb +57 -0
  19. data/lib/nanoc/extra.rb +1 -0
  20. data/lib/nanoc/filters/mustache.rb +1 -1
  21. data/lib/nanoc/rule_dsl/recording_executor.rb +6 -34
  22. data/lib/nanoc/rule_dsl/rule_memory_calculator.rb +42 -12
  23. data/lib/nanoc/spec.rb +1 -1
  24. data/lib/nanoc/version.rb +1 -1
  25. data/nanoc.gemspec +1 -2
  26. data/spec/contributors_spec.rb +18 -0
  27. data/spec/nanoc/base/checksummer_spec.rb +381 -0
  28. data/spec/nanoc/base/compiler_spec.rb +181 -0
  29. data/spec/nanoc/base/entities/configuration_spec.rb +49 -0
  30. data/spec/nanoc/base/entities/content_spec.rb +193 -0
  31. data/spec/nanoc/base/entities/document_spec.rb +206 -0
  32. data/spec/nanoc/base/entities/identifier_spec.rb +460 -0
  33. data/spec/nanoc/base/entities/item_rep_spec.rb +226 -0
  34. data/spec/nanoc/base/entities/item_spec.rb +3 -0
  35. data/spec/nanoc/base/entities/layout_spec.rb +3 -0
  36. data/spec/nanoc/base/entities/lazy_value_spec.rb +106 -0
  37. data/spec/nanoc/base/entities/outdatedness_status_spec.rb +113 -0
  38. data/spec/nanoc/base/entities/pattern_spec.rb +125 -0
  39. data/spec/nanoc/base/entities/processing_action_spec.rb +9 -0
  40. data/spec/nanoc/base/entities/processing_actions/filter_spec.rb +18 -0
  41. data/spec/nanoc/base/entities/processing_actions/layout_spec.rb +18 -0
  42. data/spec/nanoc/base/entities/processing_actions/snapshot_spec.rb +32 -0
  43. data/spec/nanoc/base/entities/props_spec.rb +195 -0
  44. data/spec/nanoc/base/entities/rule_memory_spec.rb +131 -0
  45. data/spec/nanoc/base/entities/site_spec.rb +73 -0
  46. data/spec/nanoc/base/feature_spec.rb +107 -0
  47. data/spec/nanoc/base/filter_spec.rb +99 -0
  48. data/spec/nanoc/base/item_rep_writer_spec.rb +131 -0
  49. data/spec/nanoc/base/plugin_registry_spec.rb +29 -0
  50. data/spec/nanoc/base/repos/checksum_store_spec.rb +133 -0
  51. data/spec/nanoc/base/repos/compiled_content_cache_spec.rb +55 -0
  52. data/spec/nanoc/base/repos/config_loader_spec.rb +243 -0
  53. data/spec/nanoc/base/repos/dependency_store_spec.rb +195 -0
  54. data/spec/nanoc/base/repos/site_loader_spec.rb +214 -0
  55. data/spec/nanoc/base/services/dependency_tracker_spec.rb +238 -0
  56. data/spec/nanoc/base/services/executor_spec.rb +495 -0
  57. data/spec/nanoc/base/services/item_rep_router_spec.rb +134 -0
  58. data/spec/nanoc/base/services/item_rep_selector_spec.rb +169 -0
  59. data/spec/nanoc/base/services/outdatedness_checker_spec.rb +370 -0
  60. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +432 -0
  61. data/spec/nanoc/base/services/pruner_spec.rb +105 -0
  62. data/spec/nanoc/base/services/temp_filename_factory_spec.rb +87 -0
  63. data/spec/nanoc/base/views/config_view_spec.rb +96 -0
  64. data/spec/nanoc/base/views/document_view_spec.rb +332 -0
  65. data/spec/nanoc/base/views/identifiable_collection_view_spec.rb +190 -0
  66. data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +18 -0
  67. data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +18 -0
  68. data/spec/nanoc/base/views/item_rep_collection_view_spec.rb +143 -0
  69. data/spec/nanoc/base/views/item_rep_view_spec.rb +265 -0
  70. data/spec/nanoc/base/views/item_view_spec.rb +341 -0
  71. data/spec/nanoc/base/views/layout_collection_view_spec.rb +18 -0
  72. data/spec/nanoc/base/views/layout_view_spec.rb +14 -0
  73. data/spec/nanoc/base/views/mutable_config_view_spec.rb +16 -0
  74. data/spec/nanoc/base/views/mutable_document_view_spec.rb +92 -0
  75. data/spec/nanoc/base/views/mutable_identifiable_collection_view_spec.rb +36 -0
  76. data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +49 -0
  77. data/spec/nanoc/base/views/mutable_item_view_spec.rb +22 -0
  78. data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +49 -0
  79. data/spec/nanoc/base/views/mutable_layout_view_spec.rb +13 -0
  80. data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +4 -0
  81. data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +137 -0
  82. data/spec/nanoc/base/views/post_compile_item_view_spec.rb +56 -0
  83. data/spec/nanoc/cli/commands/compile/file_action_printer_spec.rb +76 -0
  84. data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +66 -0
  85. data/spec/nanoc/cli/commands/compile_spec.rb +64 -0
  86. data/spec/nanoc/cli/commands/deploy_spec.rb +327 -0
  87. data/spec/nanoc/cli/commands/shell_spec.rb +54 -0
  88. data/spec/nanoc/cli/commands/show_data_spec.rb +126 -0
  89. data/spec/nanoc/cli/commands/show_rules_spec.rb +112 -0
  90. data/spec/nanoc/cli/commands/view_spec.rb +58 -0
  91. data/spec/nanoc/data_sources/filesystem_spec.rb +56 -0
  92. data/spec/nanoc/deploying/fog_spec.rb +193 -0
  93. data/spec/nanoc/extra/parallel_collection_spec.rb +108 -0
  94. data/spec/nanoc/filters/colorize_syntax/rouge_spec.rb +195 -0
  95. data/spec/nanoc/filters/less_spec.rb +120 -0
  96. data/spec/nanoc/helpers/blogging_spec.rb +216 -0
  97. data/spec/nanoc/helpers/breadcrumbs_spec.rb +133 -0
  98. data/spec/nanoc/helpers/capturing_spec.rb +181 -0
  99. data/spec/nanoc/helpers/child_parent_spec.rb +105 -0
  100. data/spec/nanoc/helpers/filtering_spec.rb +72 -0
  101. data/spec/nanoc/helpers/html_escape_spec.rb +35 -0
  102. data/spec/nanoc/helpers/link_to_spec.rb +275 -0
  103. data/spec/nanoc/helpers/rendering_spec.rb +141 -0
  104. data/spec/nanoc/helpers/tagging_spec.rb +104 -0
  105. data/spec/nanoc/helpers/text_spec.rb +58 -0
  106. data/spec/nanoc/integration/outdatedness_integration_spec.rb +208 -0
  107. data/spec/nanoc/regressions/gh_1015_spec.rb +17 -0
  108. data/spec/nanoc/regressions/gh_1031_spec.rb +54 -0
  109. data/spec/nanoc/regressions/gh_1035_spec.rb +33 -0
  110. data/spec/nanoc/regressions/gh_1040_spec.rb +22 -0
  111. data/spec/nanoc/regressions/gh_761_spec.rb +23 -0
  112. data/spec/nanoc/regressions/gh_767_spec.rb +19 -0
  113. data/spec/nanoc/regressions/gh_769_spec.rb +30 -0
  114. data/spec/nanoc/regressions/gh_776_spec.rb +43 -0
  115. data/spec/nanoc/regressions/gh_787_spec.rb +19 -0
  116. data/spec/nanoc/regressions/gh_795_spec.rb +19 -0
  117. data/spec/nanoc/regressions/gh_804_spec.rb +26 -0
  118. data/spec/nanoc/regressions/gh_807_spec.rb +17 -0
  119. data/spec/nanoc/regressions/gh_809_spec.rb +17 -0
  120. data/spec/nanoc/regressions/gh_813_spec.rb +22 -0
  121. data/spec/nanoc/regressions/gh_815_spec.rb +18 -0
  122. data/spec/nanoc/regressions/gh_828_spec.rb +23 -0
  123. data/spec/nanoc/regressions/gh_833_spec.rb +14 -0
  124. data/spec/nanoc/regressions/gh_841_spec.rb +15 -0
  125. data/spec/nanoc/regressions/gh_867_spec.rb +15 -0
  126. data/spec/nanoc/regressions/gh_882_spec.rb +29 -0
  127. data/spec/nanoc/regressions/gh_885_spec.rb +30 -0
  128. data/spec/nanoc/regressions/gh_891_spec.rb +26 -0
  129. data/spec/nanoc/regressions/gh_913_spec.rb +24 -0
  130. data/spec/nanoc/regressions/gh_928_spec.rb +5 -0
  131. data/spec/nanoc/regressions/gh_937_spec.rb +25 -0
  132. data/spec/nanoc/regressions/gh_942_spec.rb +21 -0
  133. data/spec/nanoc/regressions/gh_947_spec.rb +21 -0
  134. data/spec/nanoc/regressions/gh_948_spec.rb +16 -0
  135. data/spec/nanoc/regressions/gh_951_spec.rb +19 -0
  136. data/spec/nanoc/regressions/gh_954_spec.rb +33 -0
  137. data/spec/nanoc/regressions/gh_970a_spec.rb +17 -0
  138. data/spec/nanoc/regressions/gh_970b_spec.rb +50 -0
  139. data/spec/nanoc/regressions/gh_974_spec.rb +17 -0
  140. data/spec/nanoc/regressions/gh_981_spec.rb +21 -0
  141. data/spec/nanoc/rule_dsl/recording_executor_spec.rb +142 -0
  142. data/spec/nanoc/rule_dsl/rule_context_spec.rb +177 -0
  143. data/spec/nanoc/rule_dsl/rule_memory_calculator_spec.rb +233 -0
  144. data/spec/nanoc/rule_dsl/rules_collection_spec.rb +299 -0
  145. data/spec/regression_filenames_spec.rb +16 -0
  146. data/spec/spec_helper.rb +173 -0
  147. data/test/base/core_ext/array_spec.rb +2 -0
  148. data/test/base/core_ext/hash_spec.rb +2 -0
  149. data/test/base/core_ext/string_spec.rb +2 -0
  150. data/test/base/test_code_snippet.rb +2 -0
  151. data/test/base/test_compiler.rb +2 -0
  152. data/test/base/test_context.rb +4 -2
  153. data/test/base/test_data_source.rb +2 -0
  154. data/test/base/test_dependency_tracker.rb +2 -0
  155. data/test/base/test_directed_graph.rb +2 -0
  156. data/test/base/test_filter.rb +7 -5
  157. data/test/base/test_item.rb +2 -0
  158. data/test/base/test_item_array.rb +3 -1
  159. data/test/base/test_layout.rb +2 -0
  160. data/test/base/test_memoization.rb +2 -0
  161. data/test/base/test_notification_center.rb +2 -0
  162. data/test/base/test_outdatedness_checker.rb +2 -0
  163. data/test/base/test_plugin.rb +2 -0
  164. data/test/base/test_site.rb +2 -0
  165. data/test/base/test_store.rb +2 -0
  166. data/test/checking/checks/test_css.rb +2 -0
  167. data/test/checking/checks/test_external_links.rb +4 -2
  168. data/test/checking/checks/test_html.rb +2 -0
  169. data/test/checking/checks/test_internal_links.rb +5 -3
  170. data/test/checking/checks/test_mixed_content.rb +2 -0
  171. data/test/checking/checks/test_stale.rb +2 -0
  172. data/test/checking/test_check.rb +2 -0
  173. data/test/checking/test_dsl.rb +2 -0
  174. data/test/checking/test_runner.rb +2 -0
  175. data/test/cli/commands/test_check.rb +2 -0
  176. data/test/cli/commands/test_compile.rb +2 -0
  177. data/test/cli/commands/test_create_site.rb +2 -0
  178. data/test/cli/commands/test_help.rb +2 -0
  179. data/test/cli/commands/test_info.rb +2 -0
  180. data/test/cli/commands/test_prune.rb +2 -0
  181. data/test/cli/test_cleaning_stream.rb +2 -0
  182. data/test/cli/test_cli.rb +11 -9
  183. data/test/cli/test_error_handler.rb +2 -0
  184. data/test/cli/test_logger.rb +2 -0
  185. data/test/data_sources/test_filesystem.rb +8 -6
  186. data/test/data_sources/test_filesystem_tools.rb +2 -0
  187. data/test/deploying/test_fog.rb +2 -0
  188. data/test/deploying/test_rsync.rb +4 -2
  189. data/test/extra/core_ext/test_pathname.rb +2 -0
  190. data/test/extra/core_ext/test_time.rb +2 -0
  191. data/test/extra/test_link_collector.rb +2 -0
  192. data/test/extra/test_piper.rb +2 -0
  193. data/test/filters/colorize_syntax/test_coderay.rb +2 -0
  194. data/test/filters/colorize_syntax/test_common.rb +2 -0
  195. data/test/filters/colorize_syntax/test_pygmentize.rb +2 -0
  196. data/test/filters/colorize_syntax/test_pygments.rb +2 -0
  197. data/test/filters/colorize_syntax/test_simon.rb +2 -0
  198. data/test/filters/test_asciidoc.rb +2 -0
  199. data/test/filters/test_bluecloth.rb +2 -0
  200. data/test/filters/test_coffeescript.rb +2 -0
  201. data/test/filters/test_erb.rb +7 -5
  202. data/test/filters/test_erubis.rb +6 -4
  203. data/test/filters/test_haml.rb +7 -5
  204. data/test/filters/test_handlebars.rb +2 -0
  205. data/test/filters/test_kramdown.rb +2 -0
  206. data/test/filters/test_markaby.rb +2 -0
  207. data/test/filters/test_maruku.rb +2 -0
  208. data/test/filters/test_mustache.rb +4 -2
  209. data/test/filters/test_pandoc.rb +2 -0
  210. data/test/filters/test_rainpress.rb +2 -0
  211. data/test/filters/test_rdiscount.rb +2 -0
  212. data/test/filters/test_rdoc.rb +2 -0
  213. data/test/filters/test_redcarpet.rb +2 -0
  214. data/test/filters/test_redcloth.rb +2 -0
  215. data/test/filters/test_relativize_paths.rb +2 -0
  216. data/test/filters/test_rubypants.rb +2 -0
  217. data/test/filters/test_sass.rb +4 -2
  218. data/test/filters/test_slim.rb +4 -2
  219. data/test/filters/test_typogruby.rb +2 -0
  220. data/test/filters/test_uglify_js.rb +2 -0
  221. data/test/filters/test_xsl.rb +2 -0
  222. data/test/filters/test_yui_compressor.rb +5 -3
  223. data/test/helpers/test_blogging.rb +2 -0
  224. data/test/helpers/test_capturing.rb +2 -0
  225. data/test/helpers/test_link_to.rb +2 -0
  226. data/test/helpers/test_xml_sitemap.rb +2 -0
  227. data/test/rule_dsl/test_action_provider.rb +2 -0
  228. data/test/rule_dsl/test_compiler_dsl.rb +6 -4
  229. data/test/rule_dsl/test_rule.rb +2 -0
  230. data/test/rule_dsl/test_rules_collection.rb +2 -0
  231. data/test/test_gem.rb +2 -0
  232. metadata +124 -17
  233. data/test/base/test_item_rep.rb +0 -156
@@ -0,0 +1,169 @@
1
+ describe Nanoc::Int::ItemRepSelector do
2
+ let(:selector) { described_class.new(reps_for_selector) }
3
+
4
+ let(:item) do
5
+ Nanoc::Int::Item.new('stuff', {}, '/foo.md')
6
+ end
7
+
8
+ let(:reps_array) do
9
+ [
10
+ Nanoc::Int::ItemRep.new(item, :a),
11
+ Nanoc::Int::ItemRep.new(item, :b),
12
+ Nanoc::Int::ItemRep.new(item, :c),
13
+ Nanoc::Int::ItemRep.new(item, :d),
14
+ Nanoc::Int::ItemRep.new(item, :e),
15
+ ]
16
+ end
17
+
18
+ let(:reps_for_selector) { reps_array }
19
+
20
+ let(:names_to_reps) do
21
+ reps_array.each_with_object({}) do |rep, acc|
22
+ acc[rep.name] = rep
23
+ end
24
+ end
25
+
26
+ let(:dependencies) { {} }
27
+
28
+ let(:result) do
29
+ tentatively_yielded = []
30
+ successfully_yielded = []
31
+ selector.each do |rep|
32
+ tentatively_yielded << rep.name
33
+
34
+ dependencies.fetch(rep.name, []).each do |name|
35
+ unless successfully_yielded.include?(name)
36
+ raise Nanoc::Int::Errors::UnmetDependency.new(names_to_reps[name])
37
+ end
38
+ end
39
+
40
+ successfully_yielded << rep.name
41
+ end
42
+
43
+ [tentatively_yielded, successfully_yielded]
44
+ end
45
+
46
+ let(:tentatively_yielded) { result[0] }
47
+ let(:successfully_yielded) { result[1] }
48
+
49
+ describe 'error' do
50
+ context 'plain error' do
51
+ subject { selector.each { |_rep| raise 'heh' } }
52
+
53
+ it 'raises' do
54
+ expect { subject }.to raise_error(RuntimeError, 'heh')
55
+ end
56
+ end
57
+
58
+ context 'plain dependency error' do
59
+ subject do
60
+ idx = 0
61
+ selector.each do |_rep|
62
+ idx += 1
63
+
64
+ raise Nanoc::Int::Errors::UnmetDependency.new(reps_array[2]) if idx == 1
65
+ end
66
+ end
67
+
68
+ it 'does not raise' do
69
+ expect { subject }.not_to raise_error
70
+ end
71
+ end
72
+
73
+ context 'wrapped error' do
74
+ subject do
75
+ selector.each do |rep|
76
+ begin
77
+ raise 'heh'
78
+ rescue => e
79
+ raise Nanoc::Int::Errors::CompilationError.new(e, rep)
80
+ end
81
+ end
82
+ end
83
+
84
+ it 'raises original error' do
85
+ expect { subject }.to raise_error(Nanoc::Int::Errors::CompilationError) do |err|
86
+ expect(err.unwrap).to be_a(RuntimeError)
87
+ expect(err.unwrap.message).to eq('heh')
88
+ end
89
+ end
90
+ end
91
+
92
+ context 'wrapped dependency error' do
93
+ subject do
94
+ idx = 0
95
+ selector.each do |rep|
96
+ idx += 1
97
+
98
+ begin
99
+ raise Nanoc::Int::Errors::UnmetDependency.new(reps_array[2]) if idx == 1
100
+ rescue => e
101
+ raise Nanoc::Int::Errors::CompilationError.new(e, rep)
102
+ end
103
+ end
104
+ end
105
+
106
+ it 'does not raise' do
107
+ expect { subject }.not_to raise_error
108
+ end
109
+ end
110
+ end
111
+
112
+ describe 'yield order' do
113
+ context 'linear dependencies' do
114
+ let(:dependencies) do
115
+ {
116
+ a: [:b],
117
+ b: [:c],
118
+ c: [:d],
119
+ d: [:e],
120
+ e: [],
121
+ }
122
+ end
123
+
124
+ example do
125
+ expect(successfully_yielded).to eq [:e, :d, :c, :b, :a]
126
+ expect(tentatively_yielded).to eq [:a, :b, :c, :d, :e, :d, :c, :b, :a]
127
+ end
128
+ end
129
+
130
+ context 'no dependencies' do
131
+ let(:dependencies) do
132
+ {}
133
+ end
134
+
135
+ example do
136
+ expect(successfully_yielded).to eq [:a, :b, :c, :d, :e]
137
+ expect(tentatively_yielded).to eq [:a, :b, :c, :d, :e]
138
+ end
139
+ end
140
+
141
+ context 'star dependencies' do
142
+ let(:dependencies) do
143
+ {
144
+ a: [:b, :c, :d, :e],
145
+ }
146
+ end
147
+
148
+ example do
149
+ expect(successfully_yielded).to eq [:b, :c, :d, :e, :a]
150
+ expect(tentatively_yielded).to eq [:a, :b, :c, :d, :e, :a]
151
+ end
152
+ end
153
+
154
+ context 'star dependencies; selectively recompiling' do
155
+ let(:reps_for_selector) { reps_array.first(1) }
156
+
157
+ let(:dependencies) do
158
+ {
159
+ a: [:b, :c, :d, :e],
160
+ }
161
+ end
162
+
163
+ example do
164
+ expect(successfully_yielded).to eq [:b, :c, :d, :e, :a]
165
+ expect(tentatively_yielded).to eq [:a, :b, :a, :c, :a, :d, :a, :e, :a]
166
+ end
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,370 @@
1
+ describe Nanoc::Int::OutdatednessChecker do
2
+ let(:outdatedness_checker) do
3
+ described_class.new(
4
+ site: site,
5
+ checksum_store: checksum_store,
6
+ dependency_store: dependency_store,
7
+ rule_memory_store: rule_memory_store,
8
+ action_provider: action_provider,
9
+ reps: reps,
10
+ )
11
+ end
12
+
13
+ let(:site) { double(:site) }
14
+ let(:checksum_store) { double(:checksum_store) }
15
+ let(:dependency_store) { double(:dependency_store) }
16
+
17
+ let(:rule_memory_store) do
18
+ Nanoc::Int::RuleMemoryStore.new
19
+ end
20
+
21
+ let(:old_memory_for_item_rep) do
22
+ Nanoc::Int::RuleMemory.new(item_rep).tap do |mem|
23
+ mem.add_filter(:erb, {})
24
+ end
25
+ end
26
+
27
+ let(:new_memory_for_item_rep) { old_memory_for_item_rep }
28
+
29
+ let(:action_provider) { double(:action_provider) }
30
+
31
+ let(:reps) do
32
+ Nanoc::Int::ItemRepRepo.new
33
+ end
34
+
35
+ let(:item_rep) { Nanoc::Int::ItemRep.new(item, :default) }
36
+ let(:item) { Nanoc::Int::Item.new('stuff', {}, '/foo.md') }
37
+
38
+ let(:objects) { [item] }
39
+
40
+ before do
41
+ reps << item_rep
42
+ rule_memory_store[item_rep] = old_memory_for_item_rep.serialize
43
+
44
+ allow(action_provider).to receive(:memory_for).with(item_rep).and_return(new_memory_for_item_rep)
45
+ end
46
+
47
+ describe '#basic_outdatedness_reason_for' do
48
+ subject { outdatedness_checker.send(:basic_outdatedness_reason_for, obj) }
49
+
50
+ let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: objects) }
51
+
52
+ let(:config) { Nanoc::Int::Configuration.new }
53
+
54
+ before do
55
+ checksum_store.add(item)
56
+
57
+ allow(site).to receive(:code_snippets).and_return([])
58
+ allow(site).to receive(:config).and_return(config)
59
+ end
60
+
61
+ context 'with item' do
62
+ let(:obj) { item }
63
+
64
+ context 'rule memory differs' do
65
+ let(:new_memory_for_item_rep) do
66
+ Nanoc::Int::RuleMemory.new(item_rep).tap do |mem|
67
+ mem.add_filter(:super_erb, {})
68
+ end
69
+ end
70
+
71
+ it 'is outdated due to rule differences' do
72
+ expect(subject).to eql(Nanoc::Int::OutdatednessReasons::RulesModified)
73
+ end
74
+ end
75
+
76
+ # …
77
+ end
78
+
79
+ context 'with item rep' do
80
+ let(:obj) { item_rep }
81
+
82
+ context 'rule memory differs' do
83
+ let(:new_memory_for_item_rep) do
84
+ Nanoc::Int::RuleMemory.new(item_rep).tap do |mem|
85
+ mem.add_filter(:super_erb, {})
86
+ end
87
+ end
88
+
89
+ it 'is outdated due to rule differences' do
90
+ expect(subject).to eql(Nanoc::Int::OutdatednessReasons::RulesModified)
91
+ end
92
+ end
93
+
94
+ # …
95
+ end
96
+
97
+ context 'with layout' do
98
+ # …
99
+ end
100
+ end
101
+
102
+ describe '#outdated_due_to_dependencies?' do
103
+ subject { outdatedness_checker.send(:outdated_due_to_dependencies?, item) }
104
+
105
+ let(:dependency_store) do
106
+ Nanoc::Int::DependencyStore.new(objects)
107
+ end
108
+
109
+ let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: objects) }
110
+
111
+ let(:other_item) { Nanoc::Int::Item.new('other stuff', {}, '/other.md') }
112
+ let(:other_item_rep) { Nanoc::Int::ItemRep.new(other_item, :default) }
113
+
114
+ let(:config) { Nanoc::Int::Configuration.new }
115
+
116
+ let(:objects) { [item, other_item] }
117
+
118
+ let(:old_memory_for_other_item_rep) do
119
+ Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem|
120
+ mem.add_filter(:erb, {})
121
+ end
122
+ end
123
+
124
+ let(:new_memory_for_other_item_rep) { old_memory_for_other_item_rep }
125
+
126
+ before do
127
+ reps << other_item_rep
128
+ rule_memory_store[other_item_rep] = old_memory_for_other_item_rep.serialize
129
+ checksum_store.add(item)
130
+ checksum_store.add(other_item)
131
+ checksum_store.add(config)
132
+
133
+ allow(action_provider).to receive(:memory_for).with(other_item_rep).and_return(new_memory_for_other_item_rep)
134
+ allow(site).to receive(:code_snippets).and_return([])
135
+ allow(site).to receive(:config).and_return(config)
136
+ end
137
+
138
+ context 'transitive dependency' do
139
+ let(:distant_item) { Nanoc::Int::Item.new('distant stuff', {}, '/distant.md') }
140
+ let(:distant_item_rep) { Nanoc::Int::ItemRep.new(distant_item, :default) }
141
+
142
+ before do
143
+ reps << distant_item_rep
144
+ checksum_store.add(distant_item)
145
+ rule_memory_store[distant_item_rep] = old_memory_for_other_item_rep.serialize
146
+ allow(action_provider).to receive(:memory_for).with(distant_item_rep).and_return(new_memory_for_other_item_rep)
147
+ end
148
+
149
+ context 'on attribute + attribute' do
150
+ before do
151
+ dependency_store.record_dependency(item, other_item, attributes: true)
152
+ dependency_store.record_dependency(other_item, distant_item, attributes: true)
153
+ end
154
+
155
+ context 'distant attribute changed' do
156
+ before { distant_item.attributes[:title] = 'omg new title' }
157
+
158
+ it 'has correct outdatedness of item' do
159
+ expect(outdatedness_checker.send(:outdated_due_to_dependencies?, item)).not_to be
160
+ end
161
+
162
+ it 'has correct outdatedness of other item' do
163
+ expect(outdatedness_checker.send(:outdated_due_to_dependencies?, other_item)).to be
164
+ end
165
+ end
166
+
167
+ context 'distant raw content changed' do
168
+ before { distant_item.content = Nanoc::Int::TextualContent.new('omg new content') }
169
+
170
+ it 'has correct outdatedness of item' do
171
+ expect(outdatedness_checker.send(:outdated_due_to_dependencies?, item)).not_to be
172
+ end
173
+
174
+ it 'has correct outdatedness of other item' do
175
+ expect(outdatedness_checker.send(:outdated_due_to_dependencies?, other_item)).not_to be
176
+ end
177
+ end
178
+ end
179
+
180
+ context 'on compiled content + attribute' do
181
+ before do
182
+ dependency_store.record_dependency(item, other_item, compiled_content: true)
183
+ dependency_store.record_dependency(other_item, distant_item, attributes: true)
184
+ end
185
+
186
+ context 'distant attribute changed' do
187
+ before { distant_item.attributes[:title] = 'omg new title' }
188
+
189
+ it 'has correct outdatedness of item' do
190
+ expect(outdatedness_checker.send(:outdated_due_to_dependencies?, item)).to be
191
+ end
192
+
193
+ it 'has correct outdatedness of other item' do
194
+ expect(outdatedness_checker.send(:outdated_due_to_dependencies?, other_item)).to be
195
+ end
196
+ end
197
+
198
+ context 'distant raw content changed' do
199
+ before { distant_item.content = Nanoc::Int::TextualContent.new('omg new content') }
200
+
201
+ it 'has correct outdatedness of item' do
202
+ expect(outdatedness_checker.send(:outdated_due_to_dependencies?, item)).not_to be
203
+ end
204
+
205
+ it 'has correct outdatedness of other item' do
206
+ expect(outdatedness_checker.send(:outdated_due_to_dependencies?, other_item)).not_to be
207
+ end
208
+ end
209
+ end
210
+ end
211
+
212
+ context 'only attribute dependency' do
213
+ before do
214
+ dependency_store.record_dependency(item, other_item, attributes: true)
215
+ end
216
+
217
+ context 'attribute changed' do
218
+ before { other_item.attributes[:title] = 'omg new title' }
219
+ it { is_expected.to be }
220
+ end
221
+
222
+ context 'raw content changed' do
223
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
224
+ it { is_expected.not_to be }
225
+ end
226
+
227
+ context 'attribute + raw content changed' do
228
+ before { other_item.attributes[:title] = 'omg new title' }
229
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
230
+ it { is_expected.to be }
231
+ end
232
+
233
+ context 'path changed' do
234
+ let(:new_memory_for_other_item_rep) do
235
+ Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem|
236
+ mem.add_filter(:erb, {})
237
+ mem.add_snapshot(:donkey, '/giraffe.txt')
238
+ end
239
+ end
240
+
241
+ it { is_expected.not_to be }
242
+ end
243
+ end
244
+
245
+ context 'only raw content dependency' do
246
+ before do
247
+ dependency_store.record_dependency(item, other_item, raw_content: true)
248
+ end
249
+
250
+ context 'attribute changed' do
251
+ before { other_item.attributes[:title] = 'omg new title' }
252
+ it { is_expected.not_to be }
253
+ end
254
+
255
+ context 'raw content changed' do
256
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
257
+ it { is_expected.to be }
258
+ end
259
+
260
+ context 'attribute + raw content changed' do
261
+ before { other_item.attributes[:title] = 'omg new title' }
262
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
263
+ it { is_expected.to be }
264
+ end
265
+
266
+ context 'path changed' do
267
+ let(:new_memory_for_other_item_rep) do
268
+ Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem|
269
+ mem.add_filter(:erb, {})
270
+ mem.add_snapshot(:donkey, '/giraffe.txt')
271
+ end
272
+ end
273
+
274
+ it { is_expected.not_to be }
275
+ end
276
+ end
277
+
278
+ context 'only path dependency' do
279
+ before do
280
+ dependency_store.record_dependency(item, other_item, raw_content: true)
281
+ end
282
+
283
+ context 'attribute changed' do
284
+ before { other_item.attributes[:title] = 'omg new title' }
285
+ it { is_expected.not_to be }
286
+ end
287
+
288
+ context 'raw content changed' do
289
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
290
+ it { is_expected.to be }
291
+ end
292
+
293
+ context 'path changed' do
294
+ let(:new_memory_for_other_item_rep) do
295
+ Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem|
296
+ mem.add_filter(:erb, {})
297
+ mem.add_snapshot(:donkey, '/giraffe.txt')
298
+ end
299
+ end
300
+
301
+ it { is_expected.not_to be }
302
+ end
303
+ end
304
+
305
+ context 'attribute + raw content dependency' do
306
+ before do
307
+ dependency_store.record_dependency(item, other_item, attributes: true, raw_content: true)
308
+ end
309
+
310
+ context 'attribute changed' do
311
+ before { other_item.attributes[:title] = 'omg new title' }
312
+ it { is_expected.to be }
313
+ end
314
+
315
+ context 'raw content changed' do
316
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
317
+ it { is_expected.to be }
318
+ end
319
+
320
+ context 'attribute + raw content changed' do
321
+ before { other_item.attributes[:title] = 'omg new title' }
322
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
323
+ it { is_expected.to be }
324
+ end
325
+
326
+ context 'rules changed' do
327
+ let(:new_memory_for_other_item_rep) do
328
+ Nanoc::Int::RuleMemory.new(other_item_rep).tap do |mem|
329
+ mem.add_filter(:erb, {})
330
+ mem.add_filter(:donkey, {})
331
+ end
332
+ end
333
+
334
+ it { is_expected.not_to be }
335
+ end
336
+ end
337
+
338
+ context 'attribute + other dependency' do
339
+ before do
340
+ dependency_store.record_dependency(item, other_item, attributes: true, path: true)
341
+ end
342
+
343
+ context 'attribute changed' do
344
+ before { other_item.attributes[:title] = 'omg new title' }
345
+ it { is_expected.to be }
346
+ end
347
+
348
+ context 'raw content changed' do
349
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
350
+ it { is_expected.not_to be }
351
+ end
352
+ end
353
+
354
+ context 'other dependency' do
355
+ before do
356
+ dependency_store.record_dependency(item, other_item, path: true)
357
+ end
358
+
359
+ context 'attribute changed' do
360
+ before { other_item.attributes[:title] = 'omg new title' }
361
+ it { is_expected.not_to be }
362
+ end
363
+
364
+ context 'raw content changed' do
365
+ before { other_item.content = Nanoc::Int::TextualContent.new('omg new content') }
366
+ it { is_expected.not_to be }
367
+ end
368
+ end
369
+ end
370
+ end