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,208 @@
1
+ describe 'Outdatedness integration', site: true, stdio: true do
2
+ context 'only attribute dependency' do
3
+ before do
4
+ File.write('content/foo.md', "---\ntitle: hello\n---\n\nfoo")
5
+ File.write('content/bar.md', '<%= @items["/foo.*"][:title] %>')
6
+
7
+ File.write('Rules', <<EOS)
8
+ compile '/foo.*' do
9
+ write '/foo.html'
10
+ end
11
+
12
+ compile '/bar.*' do
13
+ filter :erb
14
+ write '/bar.html'
15
+ end
16
+ EOS
17
+ end
18
+
19
+ before { Nanoc::CLI.run(%w(compile)) }
20
+
21
+ it 'shows default rep outdatedness' do
22
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
23
+ output(/^item \/foo\.md, rep default:\n is not outdated/).to_stdout,
24
+ )
25
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
26
+ output(/^item \/bar\.md, rep default:\n is not outdated/).to_stdout,
27
+ )
28
+ end
29
+
30
+ it 'shows file as outdated after modification' do
31
+ File.write('content/bar.md', 'JUST BAR!')
32
+
33
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
34
+ output(/^item \/foo\.md, rep default:\n is not outdated/).to_stdout,
35
+ )
36
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
37
+ output(/^item \/bar\.md, rep default:\n is outdated: /).to_stdout,
38
+ )
39
+ end
40
+
41
+ it 'shows file and dependencies as not outdated after content modification' do
42
+ File.write('content/foo.md', "---\ntitle: hello\n---\n\nfoooOoooOOoooOooo")
43
+
44
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
45
+ output(/^item \/foo\.md, rep default:\n is outdated: /).to_stdout,
46
+ )
47
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
48
+ output(/^item \/bar\.md, rep default:\n is not outdated/).to_stdout,
49
+ )
50
+ end
51
+
52
+ it 'shows file and dependencies as outdated after title modification' do
53
+ File.write('content/foo.md', "---\ntitle: bye\n---\n\nfoo")
54
+
55
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
56
+ output(/^item \/foo\.md, rep default:\n is outdated: /).to_stdout,
57
+ )
58
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
59
+ output(/^item \/bar\.md, rep default:\n is outdated: /).to_stdout,
60
+ )
61
+ end
62
+ end
63
+
64
+ context 'only raw content dependency' do
65
+ before do
66
+ File.write('content/foo.md', "---\ntitle: hello\n---\n\nfoo")
67
+ File.write('content/bar.md', '<%= @items["/foo.*"].raw_content %>')
68
+
69
+ File.write('Rules', <<EOS)
70
+ compile '/foo.*' do
71
+ write '/foo.html'
72
+ end
73
+
74
+ compile '/bar.*' do
75
+ filter :erb
76
+ write '/bar.html'
77
+ end
78
+ EOS
79
+ end
80
+
81
+ before { Nanoc::CLI.run(%w(compile)) }
82
+
83
+ it 'shows default rep outdatedness' do
84
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
85
+ output(/^item \/foo\.md, rep default:\n is not outdated/).to_stdout,
86
+ )
87
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
88
+ output(/^item \/bar\.md, rep default:\n is not outdated/).to_stdout,
89
+ )
90
+ end
91
+
92
+ it 'shows file as outdated after modification' do
93
+ File.write('content/bar.md', 'JUST BAR!')
94
+
95
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
96
+ output(/^item \/foo\.md, rep default:\n is not outdated/).to_stdout,
97
+ )
98
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
99
+ output(/^item \/bar\.md, rep default:\n is outdated: /).to_stdout,
100
+ )
101
+ end
102
+
103
+ it 'shows file and dependencies as outdated after content modification' do
104
+ File.write('content/foo.md', "---\ntitle: hello\n---\n\nfoooOoooOOoooOooo")
105
+
106
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
107
+ output(/^item \/foo\.md, rep default:\n is outdated: /).to_stdout,
108
+ )
109
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
110
+ output(/^item \/bar\.md, rep default:\n is outdated: /).to_stdout,
111
+ )
112
+ end
113
+
114
+ it 'shows file and dependencies as not outdated after title modification' do
115
+ File.write('content/foo.md', "---\ntitle: bye\n---\n\nfoo")
116
+
117
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
118
+ output(/^item \/foo\.md, rep default:\n is outdated: /).to_stdout,
119
+ )
120
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
121
+ output(/^item \/bar\.md, rep default:\n is not outdated/).to_stdout,
122
+ )
123
+ end
124
+ end
125
+
126
+ context 'attribute and raw content dependency' do
127
+ before do
128
+ File.write('content/foo.md', "---\ntitle: hello\n---\n\nfoo")
129
+ File.write('content/bar.md', '<%= @items["/foo.*"].raw_content %> / <%= @items["/foo.*"][:title] %>')
130
+
131
+ File.write('Rules', <<EOS)
132
+ compile '/foo.*' do
133
+ write '/foo.html'
134
+ end
135
+
136
+ compile '/bar.*' do
137
+ filter :erb
138
+ write '/bar.html'
139
+ end
140
+ EOS
141
+ end
142
+
143
+ before { Nanoc::CLI.run(%w(compile)) }
144
+
145
+ it 'shows default rep outdatedness' do
146
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
147
+ output(/^item \/foo\.md, rep default:\n is not outdated/).to_stdout,
148
+ )
149
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
150
+ output(/^item \/bar\.md, rep default:\n is not outdated/).to_stdout,
151
+ )
152
+ end
153
+
154
+ it 'shows file as outdated after modification' do
155
+ File.write('content/bar.md', 'JUST BAR!')
156
+
157
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
158
+ output(/^item \/foo\.md, rep default:\n is not outdated/).to_stdout,
159
+ )
160
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
161
+ output(/^item \/bar\.md, rep default:\n is outdated: /).to_stdout,
162
+ )
163
+ end
164
+
165
+ it 'shows file and dependencies as outdated after content modification' do
166
+ File.write('content/foo.md', "---\ntitle: hello\n---\n\nfoooOoooOOoooOooo")
167
+
168
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
169
+ output(/^item \/foo\.md, rep default:\n is outdated: /).to_stdout,
170
+ )
171
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
172
+ output(/^item \/bar\.md, rep default:\n is outdated: /).to_stdout,
173
+ )
174
+ end
175
+
176
+ it 'shows file and dependencies as outdated after title modification' do
177
+ File.write('content/foo.md', "---\ntitle: bye\n---\n\nfoo")
178
+
179
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
180
+ output(/^item \/foo\.md, rep default:\n is outdated: /).to_stdout,
181
+ )
182
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
183
+ output(/^item \/bar\.md, rep default:\n is outdated: /).to_stdout,
184
+ )
185
+ end
186
+
187
+ it 'shows file and dependencies as not outdated after rule modification' do
188
+ File.write('Rules', <<EOS)
189
+ compile '/foo.*' do
190
+ filter :erb
191
+ write '/foo.html'
192
+ end
193
+
194
+ compile '/bar.*' do
195
+ filter :erb
196
+ write '/bar.html'
197
+ end
198
+ EOS
199
+
200
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
201
+ output(/^item \/foo\.md, rep default:\n is outdated: /).to_stdout,
202
+ )
203
+ expect { Nanoc::CLI.run(%w(show-data --no-color)) }.to(
204
+ output(/^item \/bar\.md, rep default:\n is not outdated/).to_stdout,
205
+ )
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,17 @@
1
+ describe 'GH-1015', site: true, stdio: true do
2
+ before do
3
+ File.write('content/foo.md', 'I am foo!')
4
+
5
+ File.write('Rules', <<EOS)
6
+ compile '/foo.*' do
7
+ filter :erb, stuff: self
8
+ write 'foo.html'
9
+ end
10
+ EOS
11
+ end
12
+
13
+ it 'errors' do
14
+ expect { Nanoc::CLI.run(%w(compile --verbose)) }.to raise_exception(Nanoc::Int::ItemRepRouter::RouteWithoutSlashError)
15
+ expect(File.file?('outputfoo.html')).not_to be
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ describe 'GH-1031', site: true, stdio: true do
2
+ before do
3
+ File.write('content/foo.md', '[<%= @items["/bar.*"].compiled_content %>]')
4
+ File.write('content/bar.md', 'I am bar!')
5
+
6
+ File.write('Rules', <<EOS)
7
+ compile '/bar.*' do
8
+ write '/bar.txt'
9
+ end
10
+
11
+ compile '/foo.*', rep: :default do
12
+ write '/foo.txt'
13
+ end
14
+
15
+ compile '/foo.*', rep: :depz do
16
+ filter :erb
17
+ write '/foo_deps.txt'
18
+ end
19
+ EOS
20
+ end
21
+
22
+ it 'recompiles all reps of a changed item' do
23
+ Nanoc::CLI.run(%w(compile))
24
+ expect(File.file?('output/bar.txt')).to be
25
+ expect(File.file?('output/foo.txt')).to be
26
+ expect(File.file?('output/foo_deps.txt')).to be
27
+
28
+ File.write('Rules', <<EOS)
29
+ compile '/bar.*' do
30
+ write '/bar.txt'
31
+ end
32
+
33
+ compile '/foo.*', rep: :default do
34
+ write '/foo-new.txt'
35
+ end
36
+
37
+ compile '/foo.*', rep: :depz do
38
+ filter :erb
39
+ write '/foo_deps.txt'
40
+ end
41
+ EOS
42
+
43
+ Nanoc::CLI.run(%w(compile))
44
+ expect(File.file?('output/bar.txt')).to be
45
+ expect(File.file?('output/foo.txt')).to be
46
+ expect(File.file?('output/foo_deps.txt')).to be
47
+ expect(File.read('output/foo_deps.txt')).to eq('[I am bar!]')
48
+
49
+ File.write('content/bar.md', 'I am a newer bar!')
50
+
51
+ Nanoc::CLI.run(%w(compile))
52
+ expect(File.read('output/foo_deps.txt')).to eq('[I am a newer bar!]')
53
+ end
54
+ end
@@ -0,0 +1,33 @@
1
+ describe 'GH-1035', site: true, stdio: true do
2
+ before do
3
+ File.write('content/foo.md', '[<%= @items["/bar.*"].compiled_content(snapshot: :raw) %>]')
4
+ File.write('content/bar.md', 'I am bar!')
5
+
6
+ File.write('lib/stuff.rb', <<EOS)
7
+ Class.new(Nanoc::Filter) do
8
+ identifier :gh_1031_text2bin
9
+ type :text => :binary
10
+
11
+ def run(content, params = {})
12
+ File.write(output_filename, content)
13
+ end
14
+ end
15
+ EOS
16
+
17
+ File.write('Rules', <<EOS)
18
+ compile '/bar.*' do
19
+ filter :gh_1031_text2bin
20
+ end
21
+
22
+ compile '/foo.*' do
23
+ filter :erb
24
+ write '/foo.txt'
25
+ end
26
+ EOS
27
+ end
28
+
29
+ it 'can access textual content of now-binary item' do
30
+ Nanoc::CLI.run(%w(compile))
31
+ expect(File.read('output/foo.txt')).to eql('[I am bar!]')
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ describe 'GH-1040', site: true, stdio: true do
2
+ before do
3
+ File.write('content/foo.txt', 'bar=<%= @items["/bar.*"].compiled_content %>')
4
+ File.write('content/bar.txt', 'foo=<%= @items["/foo.*"].compiled_content %>')
5
+
6
+ File.write('layouts/default.erb', '*<%= yield %>*')
7
+
8
+ File.write('Rules', <<EOS)
9
+ compile '/*' do
10
+ filter :erb
11
+ layout '/default.*'
12
+ write item.identifier
13
+ end
14
+
15
+ layout '/*.erb', :erb
16
+ EOS
17
+ end
18
+
19
+ it 'errors' do
20
+ expect { Nanoc::CLI.run(%w(compile)) }.to raise_error(Nanoc::Int::Errors::RecursiveCompilation)
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ describe 'GH-761', site: true do
2
+ before do
3
+ File.write('content/donkey.md', 'Compiled content donkey!')
4
+
5
+ File.write('layouts/foo.erb', '[<%= @item.compiled_content %>]')
6
+
7
+ File.write('Rules', <<EOS)
8
+ compile '/**/*' do
9
+ layout '/foo.*'
10
+ write '/donkey.html'
11
+ end
12
+
13
+ layout '/foo.*', :erb
14
+ EOS
15
+ end
16
+
17
+ it 'supports #compiled_content instead of yield' do
18
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
19
+ site.compile
20
+
21
+ expect(File.read('output/donkey.html')).to eql('[Compiled content donkey!]')
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ describe 'GH-767', site: true do
2
+ before do
3
+ File.write('content/donkey.md', 'Compiled content donkey!')
4
+
5
+ File.write('Rules', <<EOS)
6
+ compile '/**/*' do
7
+ filter :erb, stuff: item.path
8
+ write '/donkey.html'
9
+ end
10
+
11
+ layout '/foo.*', :erb
12
+ EOS
13
+ end
14
+
15
+ it 'does not expose #path on @item' do
16
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
17
+ expect { site.compile }.to raise_error(NoMethodError, /undefined method .*path.* for .*Nanoc::ItemWithoutRepsView/)
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ describe 'GH-769', site: true do
2
+ before do
3
+ File.write('content/index.md', 'Index!')
4
+ File.write('content/donkey.md', 'Donkey! [<%= @item.parent.identifier %>]')
5
+
6
+ File.open('nanoc.yaml', 'w') do |io|
7
+ io << 'string_pattern_type: legacy' << "\n"
8
+ io << 'data_sources:' << "\n"
9
+ io << ' -' << "\n"
10
+ io << ' type: filesystem' << "\n"
11
+ io << ' identifier_type: legacy' << "\n"
12
+ end
13
+
14
+ File.write('Rules', <<EOS)
15
+ compile '*' do
16
+ filter :erb
17
+ write item.identifier + 'index.html'
18
+ end
19
+
20
+ layout '/foo.*', :erb
21
+ EOS
22
+ end
23
+
24
+ it 'finds the parent if the parent is root' do
25
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
26
+ site.compile
27
+
28
+ expect(File.read('output/donkey/index.html')).to eql('Donkey! [/]')
29
+ end
30
+ end
@@ -0,0 +1,43 @@
1
+ describe 'GH-776', site: true do
2
+ before do
3
+ File.write('content/donkey.md', 'Donkey!')
4
+
5
+ File.write('Rules', <<EOS)
6
+ route '/donkey.*', snapshot: :secret do
7
+ '/donkey-secret.html'
8
+ end
9
+
10
+ compile '/donkey.*' do
11
+ filter :erb
12
+ snapshot :secret
13
+ write '/donkey.html'
14
+ end
15
+
16
+ layout '/foo.*', :erb
17
+ EOS
18
+ end
19
+
20
+ let(:site) { Nanoc::Int::SiteLoader.new.new_from_cwd }
21
+
22
+ before do
23
+ site.compile
24
+ end
25
+
26
+ context 'without pruning' do
27
+ it 'writes two files' do
28
+ expect(File.read('output/donkey.html')).to eql('Donkey!')
29
+ expect(File.read('output/donkey-secret.html')).to eql('Donkey!')
30
+ end
31
+ end
32
+
33
+ context 'with pruning' do
34
+ before do
35
+ Nanoc::Pruner.new(site.config, site.compiler.reps).run
36
+ end
37
+
38
+ it 'does not prune written snapshots' do
39
+ expect(File.read('output/donkey.html')).to eql('Donkey!')
40
+ expect(File.read('output/donkey-secret.html')).to eql('Donkey!')
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ describe 'GH-787', site: true, stdio: true do
2
+ before do
3
+ File.write('Rules', <<EOS)
4
+ preprocess do
5
+ @items.create('foo', {}, '/pig.md')
6
+ end
7
+
8
+ compile '/**/*' do
9
+ write '/oink.html'
10
+ end
11
+
12
+ layout '/foo.*', :erb
13
+ EOS
14
+ end
15
+
16
+ it 'runs the preprocessor only once' do
17
+ expect { Nanoc::CLI.run(['compile']) }.not_to raise_error
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ describe 'GH-795', site: true, stdio: true do
2
+ before do
3
+ File.write('content/items.md', 'Frozen? <%= @items.unwrap.frozen? %>!')
4
+ File.write('content/items-view.md', 'Frozen? <%= @items.frozen? %>!')
5
+ File.write('Rules', <<EOS)
6
+ compile '/**/*' do
7
+ filter :erb
8
+ write item.identifier.without_ext + '.html'
9
+ end
10
+ EOS
11
+ end
12
+
13
+ it 'freezes @items' do
14
+ Nanoc::CLI.run(['compile'])
15
+
16
+ expect(File.read('output/items.html')).to eql('Frozen? true!')
17
+ expect(File.read('output/items-view.html')).to eql('Frozen? true!')
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ describe 'GH-804', site: true, stdio: true do
2
+ before do
3
+ File.write('content/item.md', 'Stuff!')
4
+ File.write('Rules', <<EOS)
5
+ compile '/**/*' do
6
+ filter :erb if item[:dynamic]
7
+ write item.identifier.without_ext + '.html'
8
+ end
9
+ EOS
10
+
11
+ File.write('Checks', <<EOS)
12
+ check :donkey do
13
+ self.add_issue('Not enough donkeys')
14
+ self.add_issue('Too many cats', subject: '/catlady.md')
15
+ end
16
+ EOS
17
+ end
18
+
19
+ it 'does not crash' do
20
+ expect { Nanoc::CLI.run(%w(check donkey)) }.to(
21
+ raise_error(Nanoc::Int::Errors::GenericTrivial, 'One or more checks failed').and(
22
+ output(/Issues found!\n \(global\):\n \[ (\e\[31m)?ERROR(\e\[0m)? \] donkey - Not enough donkeys\n \/catlady.md:\n \[ (\e\[31m)?ERROR(\e\[0m)? \] donkey - Too many cats\n/).to_stdout,
23
+ ),
24
+ )
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ describe 'GH-807', site: true, stdio: true do
2
+ before do
3
+ File.write('content/item.md', 'Stuff!')
4
+ File.write('Rules', <<EOS)
5
+ compile '/**/*' do
6
+ filter :erb if item[:dynamic]
7
+ write item.identifier.without_ext + '.html'
8
+ end
9
+ EOS
10
+ end
11
+
12
+ it 'does not crash' do
13
+ Nanoc::CLI.run(['compile'])
14
+
15
+ expect(File.read('output/item.html')).to eql('Stuff!')
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ describe 'GH-809', site: true, stdio: true do
2
+ before do
3
+ File.write('content/greeting.md', 'Hallöchen!')
4
+ File.write('Rules', <<EOS)
5
+ compile '/**/*' do
6
+ snapshot :something, path: '/greeting.tmp'
7
+ end
8
+ EOS
9
+ end
10
+
11
+ specify 'stale check does not consider output/greeting.tmp as stale' do
12
+ Nanoc::CLI.run(['compile'])
13
+
14
+ regex = /Running check stale… (\e\[32m)?ok(\e\[0m)?/
15
+ expect { Nanoc::CLI.run(%w(check stale)) }.to output(regex).to_stdout
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ describe 'GH-813', site: true, stdio: true do
2
+ before do
3
+ File.write('nanoc.yaml', "enable_output_diff: true\n")
4
+ File.write('content/greeting.md', 'Hallöchen!')
5
+ File.write('Rules', <<EOS)
6
+ compile '/**/*' do
7
+ snapshot :donkey, path: '/donkey.html'
8
+ filter :kramdown
9
+ end
10
+ EOS
11
+
12
+ Nanoc::CLI.run(['compile'])
13
+ end
14
+
15
+ specify 'Nanoc generates diff for proper path' do
16
+ File.write('content/greeting.md', 'Hellosies!')
17
+ Nanoc::CLI.run(['compile'])
18
+
19
+ diff = File.read('output.diff')
20
+ expect(diff).to start_with("--- output/donkey.html\n+++ output/donkey.html\n")
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ describe 'GH-815', site: true, stdio: true do
2
+ before do
3
+ File.write('nanoc.yaml', "animal: \"donkey\"\n")
4
+ File.write('content/foo.md', '<%= @config.key?(:animal) %>')
5
+ File.write('Rules', <<EOS)
6
+ compile '/**/*' do
7
+ filter :erb
8
+ write item.identifier.without_ext + '.txt'
9
+ end
10
+ EOS
11
+ end
12
+
13
+ it 'handles #key? properly' do
14
+ Nanoc::CLI.run(['compile'])
15
+
16
+ expect(File.read('output/foo.txt')).to eql('true')
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ describe 'GH-828', site: true, stdio: true do
2
+ before do
3
+ File.write('content/bad.md', "---\nbad: true\n---\n\nI am bad!")
4
+ File.write('content/good.md', "---\nbad: false\n---\n\nI am good!")
5
+ File.write('Rules', <<EOS)
6
+ preprocess do
7
+ @items.delete_if { |i| i[:bad] }
8
+ end
9
+
10
+ compile '/**/*' do
11
+ filter :erb
12
+ write item.identifier.without_ext + '.txt'
13
+ end
14
+ EOS
15
+ end
16
+
17
+ it 'only writes good page' do
18
+ Nanoc::CLI.run(['compile'])
19
+
20
+ expect(File.file?('output/good.txt')).to be
21
+ expect(File.file?('output/bad.txt')).not_to be
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ describe 'GH-833', site: true, stdio: true do
2
+ before do
3
+ File.write('content/foo.md', 'stuff')
4
+ File.write('Rules', <<EOS)
5
+ compile '/**/*' do
6
+ write item.identifier.without_ext + '.txt'
7
+ end
8
+ EOS
9
+ end
10
+
11
+ it 'runs show-data without crashing' do
12
+ Nanoc::CLI.run(['show-data'])
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ describe 'GH-841', site: true, stdio: true do
2
+ before do
3
+ File.write('content/foo.md', 'stuff')
4
+
5
+ File.write('Rules', <<EOS)
6
+ preprocess do
7
+ items.delete_if { |_| true }
8
+ end
9
+ EOS
10
+ end
11
+
12
+ it 'preprocesses before running the check' do
13
+ Nanoc::CLI.run(%w(check stale))
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ describe 'GH-867', site: true, stdio: true do
2
+ before do
3
+ File.write('content/foo.md', 'stuff')
4
+
5
+ File.write('Rules', <<EOS)
6
+ preprocess do
7
+ items.delete_if { |_| true }
8
+ end
9
+ EOS
10
+ end
11
+
12
+ it 'preprocesses before running show-data' do
13
+ expect { Nanoc::CLI.run(%w(show-data)) }.not_to output(/foo/).to_stdout
14
+ end
15
+ end