nanoc 4.8.12 → 4.8.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +6 -0
  3. data/lib/nanoc/base/entities/document.rb +16 -1
  4. data/lib/nanoc/base/feature.rb +1 -1
  5. data/lib/nanoc/base/repos/action_sequence_store.rb +3 -3
  6. data/lib/nanoc/base/repos/checksum_store.rb +3 -3
  7. data/lib/nanoc/base/repos/compiled_content_cache.rb +3 -3
  8. data/lib/nanoc/base/repos/dependency_store.rb +3 -3
  9. data/lib/nanoc/base/repos/outdatedness_store.rb +3 -3
  10. data/lib/nanoc/base/repos/store.rb +3 -5
  11. data/lib/nanoc/base/services/compiler_loader.rb +5 -5
  12. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +2 -14
  13. data/lib/nanoc/cli/commands/compile.rb +18 -0
  14. data/lib/nanoc/cli/commands/live.rb +1 -0
  15. data/lib/nanoc/cli/commands/view.rb +12 -35
  16. data/lib/nanoc/filters/redcarpet.rb +26 -65
  17. data/lib/nanoc/version.rb +1 -1
  18. metadata +2 -293
  19. data/.rspec +0 -3
  20. data/.rubocop.yml +0 -173
  21. data/Rakefile +0 -25
  22. data/nanoc.gemspec +0 -44
  23. data/nanoc.manifest +0 -543
  24. data/spec/contributors_spec.rb +0 -20
  25. data/spec/gem_spec.rb +0 -21
  26. data/spec/manifest_spec.rb +0 -22
  27. data/spec/nanoc/base/changes_stream_spec.rb +0 -45
  28. data/spec/nanoc/base/checksummer_spec.rb +0 -419
  29. data/spec/nanoc/base/compiler_spec.rb +0 -149
  30. data/spec/nanoc/base/core_ext/array_spec.rb +0 -35
  31. data/spec/nanoc/base/core_ext/hash_spec.rb +0 -41
  32. data/spec/nanoc/base/core_ext/string_spec.rb +0 -23
  33. data/spec/nanoc/base/directed_graph_spec.rb +0 -258
  34. data/spec/nanoc/base/entities/action_sequence_spec.rb +0 -297
  35. data/spec/nanoc/base/entities/code_snippet_spec.rb +0 -60
  36. data/spec/nanoc/base/entities/configuration_spec.rb +0 -132
  37. data/spec/nanoc/base/entities/content_spec.rb +0 -195
  38. data/spec/nanoc/base/entities/context_spec.rb +0 -26
  39. data/spec/nanoc/base/entities/document_spec.rb +0 -258
  40. data/spec/nanoc/base/entities/identifiable_collection_spec.rb +0 -209
  41. data/spec/nanoc/base/entities/identifier_spec.rb +0 -472
  42. data/spec/nanoc/base/entities/item_rep_spec.rb +0 -26
  43. data/spec/nanoc/base/entities/item_spec.rb +0 -13
  44. data/spec/nanoc/base/entities/layout_spec.rb +0 -13
  45. data/spec/nanoc/base/entities/lazy_value_spec.rb +0 -108
  46. data/spec/nanoc/base/entities/outdatedness_status_spec.rb +0 -115
  47. data/spec/nanoc/base/entities/pattern_spec.rb +0 -133
  48. data/spec/nanoc/base/entities/processing_action_spec.rb +0 -11
  49. data/spec/nanoc/base/entities/processing_actions/filter_spec.rb +0 -20
  50. data/spec/nanoc/base/entities/processing_actions/layout_spec.rb +0 -20
  51. data/spec/nanoc/base/entities/processing_actions/snapshot_spec.rb +0 -40
  52. data/spec/nanoc/base/entities/props_spec.rb +0 -413
  53. data/spec/nanoc/base/entities/site_spec.rb +0 -80
  54. data/spec/nanoc/base/errors/dependency_cycle_spec.rb +0 -35
  55. data/spec/nanoc/base/feature_spec.rb +0 -109
  56. data/spec/nanoc/base/filter_spec.rb +0 -166
  57. data/spec/nanoc/base/item_rep_writer_spec.rb +0 -140
  58. data/spec/nanoc/base/memoization_spec.rb +0 -108
  59. data/spec/nanoc/base/repos/aggregate_data_source_spec.rb +0 -87
  60. data/spec/nanoc/base/repos/checksum_store_spec.rb +0 -155
  61. data/spec/nanoc/base/repos/compiled_content_cache_spec.rb +0 -65
  62. data/spec/nanoc/base/repos/config_loader_spec.rb +0 -245
  63. data/spec/nanoc/base/repos/data_source_spec.rb +0 -95
  64. data/spec/nanoc/base/repos/dependency_store_spec.rb +0 -515
  65. data/spec/nanoc/base/repos/in_mem_data_source_spec.rb +0 -39
  66. data/spec/nanoc/base/repos/outdatedness_store_spec.rb +0 -72
  67. data/spec/nanoc/base/repos/prefixed_data_source_spec.rb +0 -39
  68. data/spec/nanoc/base/repos/site_loader_spec.rb +0 -264
  69. data/spec/nanoc/base/repos/snapshot_repo_spec.rb +0 -316
  70. data/spec/nanoc/base/repos/store_spec.rb +0 -93
  71. data/spec/nanoc/base/services/compiler/phases/abstract_spec.rb +0 -63
  72. data/spec/nanoc/base/services/compiler/phases/cache_spec.rb +0 -156
  73. data/spec/nanoc/base/services/compiler/stages/calculate_checksums_spec.rb +0 -74
  74. data/spec/nanoc/base/services/compiler/stages/cleanup_spec.rb +0 -88
  75. data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +0 -142
  76. data/spec/nanoc/base/services/compiler/stages/determine_outdatedness_spec.rb +0 -148
  77. data/spec/nanoc/base/services/compiler/stages/preprocess_spec.rb +0 -110
  78. data/spec/nanoc/base/services/dependency_tracker_spec.rb +0 -245
  79. data/spec/nanoc/base/services/executor_spec.rb +0 -686
  80. data/spec/nanoc/base/services/item_rep_router_spec.rb +0 -198
  81. data/spec/nanoc/base/services/item_rep_selector_spec.rb +0 -227
  82. data/spec/nanoc/base/services/notification_center_spec.rb +0 -25
  83. data/spec/nanoc/base/services/outdatedness_checker_spec.rb +0 -778
  84. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +0 -495
  85. data/spec/nanoc/base/services/pruner_spec.rb +0 -116
  86. data/spec/nanoc/base/services/temp_filename_factory_spec.rb +0 -89
  87. data/spec/nanoc/base/views/basic_item_rep_collection_view_spec.rb +0 -8
  88. data/spec/nanoc/base/views/basic_item_rep_view_spec.rb +0 -9
  89. data/spec/nanoc/base/views/compilation_item_rep_collection_view_spec.rb +0 -8
  90. data/spec/nanoc/base/views/compilation_item_rep_view_spec.rb +0 -136
  91. data/spec/nanoc/base/views/config_view_spec.rb +0 -144
  92. data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +0 -23
  93. data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +0 -23
  94. data/spec/nanoc/base/views/item_view_spec.rb +0 -376
  95. data/spec/nanoc/base/views/layout_collection_view_spec.rb +0 -23
  96. data/spec/nanoc/base/views/layout_view_spec.rb +0 -18
  97. data/spec/nanoc/base/views/mutable_config_view_spec.rb +0 -18
  98. data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +0 -60
  99. data/spec/nanoc/base/views/mutable_item_view_spec.rb +0 -26
  100. data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +0 -60
  101. data/spec/nanoc/base/views/mutable_layout_view_spec.rb +0 -17
  102. data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +0 -8
  103. data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +0 -216
  104. data/spec/nanoc/base/views/post_compile_item_view_spec.rb +0 -58
  105. data/spec/nanoc/base/views/support/document_view_examples.rb +0 -340
  106. data/spec/nanoc/base/views/support/identifiable_collection_view_examples.rb +0 -277
  107. data/spec/nanoc/base/views/support/item_rep_collection_view_examples.rb +0 -140
  108. data/spec/nanoc/base/views/support/item_rep_view_examples.rb +0 -308
  109. data/spec/nanoc/base/views/support/mutable_document_view_examples.rb +0 -188
  110. data/spec/nanoc/base/views/support/mutable_identifiable_collection_view_examples.rb +0 -44
  111. data/spec/nanoc/checking/runner_spec.rb +0 -26
  112. data/spec/nanoc/cli/command_runner_spec.rb +0 -107
  113. data/spec/nanoc/cli/commands/compile/abstract_spec.rb +0 -80
  114. data/spec/nanoc/cli/commands/compile/diff_generator_spec.rb +0 -44
  115. data/spec/nanoc/cli/commands/compile/file_action_printer_spec.rb +0 -112
  116. data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +0 -287
  117. data/spec/nanoc/cli/commands/compile_spec.rb +0 -45
  118. data/spec/nanoc/cli/commands/deploy_spec.rb +0 -329
  119. data/spec/nanoc/cli/commands/shell_spec.rb +0 -77
  120. data/spec/nanoc/cli/commands/show_data_spec.rb +0 -286
  121. data/spec/nanoc/cli/commands/show_plugins_spec.rb +0 -20
  122. data/spec/nanoc/cli/commands/show_rules_spec.rb +0 -118
  123. data/spec/nanoc/cli/commands/view_spec.rb +0 -75
  124. data/spec/nanoc/cli/error_handler_spec.rb +0 -43
  125. data/spec/nanoc/cli/stack_trace_writer_spec.rb +0 -156
  126. data/spec/nanoc/cli/stream_cleaners/utf8_spec.rb +0 -9
  127. data/spec/nanoc/cli_spec.rb +0 -44
  128. data/spec/nanoc/data_sources/filesystem_spec.rb +0 -128
  129. data/spec/nanoc/deploying/fog_spec.rb +0 -199
  130. data/spec/nanoc/deploying/git_spec.rb +0 -305
  131. data/spec/nanoc/extra/live_recompiler_spec.rb +0 -129
  132. data/spec/nanoc/extra/parallel_collection_spec.rb +0 -110
  133. data/spec/nanoc/filters/asciidoctor_spec.rb +0 -12
  134. data/spec/nanoc/filters/colorize_syntax/rouge_spec.rb +0 -155
  135. data/spec/nanoc/filters/less_spec.rb +0 -122
  136. data/spec/nanoc/helpers/blogging_spec.rb +0 -219
  137. data/spec/nanoc/helpers/breadcrumbs_spec.rb +0 -135
  138. data/spec/nanoc/helpers/capturing_spec.rb +0 -256
  139. data/spec/nanoc/helpers/child_parent_spec.rb +0 -76
  140. data/spec/nanoc/helpers/filtering_spec.rb +0 -77
  141. data/spec/nanoc/helpers/html_escape_spec.rb +0 -37
  142. data/spec/nanoc/helpers/link_to_spec.rb +0 -320
  143. data/spec/nanoc/helpers/rendering_spec.rb +0 -144
  144. data/spec/nanoc/helpers/tagging_spec.rb +0 -106
  145. data/spec/nanoc/helpers/text_spec.rb +0 -60
  146. data/spec/nanoc/integration/compile_command_spec.rb +0 -33
  147. data/spec/nanoc/integration/outdatedness_integration_spec.rb +0 -269
  148. data/spec/nanoc/integration/partial_recompilation_spec.rb +0 -50
  149. data/spec/nanoc/regressions/gh_1015_spec.rb +0 -19
  150. data/spec/nanoc/regressions/gh_1022_spec.rb +0 -26
  151. data/spec/nanoc/regressions/gh_1031_spec.rb +0 -56
  152. data/spec/nanoc/regressions/gh_1035_spec.rb +0 -35
  153. data/spec/nanoc/regressions/gh_1037a_spec.rb +0 -31
  154. data/spec/nanoc/regressions/gh_1037b_spec.rb +0 -20
  155. data/spec/nanoc/regressions/gh_1040_spec.rb +0 -24
  156. data/spec/nanoc/regressions/gh_1045_spec.rb +0 -50
  157. data/spec/nanoc/regressions/gh_1047_spec.rb +0 -30
  158. data/spec/nanoc/regressions/gh_1064_spec.rb +0 -20
  159. data/spec/nanoc/regressions/gh_1067_spec.rb +0 -36
  160. data/spec/nanoc/regressions/gh_1082a_spec.rb +0 -20
  161. data/spec/nanoc/regressions/gh_1082b_spec.rb +0 -22
  162. data/spec/nanoc/regressions/gh_1082c_spec.rb +0 -21
  163. data/spec/nanoc/regressions/gh_1082d_spec.rb +0 -19
  164. data/spec/nanoc/regressions/gh_1093_spec.rb +0 -51
  165. data/spec/nanoc/regressions/gh_1094_spec.rb +0 -24
  166. data/spec/nanoc/regressions/gh_1097_spec.rb +0 -23
  167. data/spec/nanoc/regressions/gh_1100_spec.rb +0 -22
  168. data/spec/nanoc/regressions/gh_1102_spec.rb +0 -28
  169. data/spec/nanoc/regressions/gh_1107_spec.rb +0 -15
  170. data/spec/nanoc/regressions/gh_1130_spec.rb +0 -21
  171. data/spec/nanoc/regressions/gh_1134_spec.rb +0 -29
  172. data/spec/nanoc/regressions/gh_1145_spec.rb +0 -18
  173. data/spec/nanoc/regressions/gh_1171_spec.rb +0 -57
  174. data/spec/nanoc/regressions/gh_1185_spec.rb +0 -22
  175. data/spec/nanoc/regressions/gh_1216_spec.rb +0 -91
  176. data/spec/nanoc/regressions/gh_1248_spec.rb +0 -24
  177. data/spec/nanoc/regressions/gh_761_spec.rb +0 -25
  178. data/spec/nanoc/regressions/gh_767_spec.rb +0 -21
  179. data/spec/nanoc/regressions/gh_769_spec.rb +0 -32
  180. data/spec/nanoc/regressions/gh_776_spec.rb +0 -42
  181. data/spec/nanoc/regressions/gh_787_spec.rb +0 -21
  182. data/spec/nanoc/regressions/gh_795_spec.rb +0 -21
  183. data/spec/nanoc/regressions/gh_804_spec.rb +0 -28
  184. data/spec/nanoc/regressions/gh_807_spec.rb +0 -19
  185. data/spec/nanoc/regressions/gh_809_spec.rb +0 -19
  186. data/spec/nanoc/regressions/gh_813_spec.rb +0 -24
  187. data/spec/nanoc/regressions/gh_815_spec.rb +0 -20
  188. data/spec/nanoc/regressions/gh_828_spec.rb +0 -25
  189. data/spec/nanoc/regressions/gh_833_spec.rb +0 -16
  190. data/spec/nanoc/regressions/gh_841_spec.rb +0 -17
  191. data/spec/nanoc/regressions/gh_867_spec.rb +0 -17
  192. data/spec/nanoc/regressions/gh_882_spec.rb +0 -31
  193. data/spec/nanoc/regressions/gh_885_spec.rb +0 -32
  194. data/spec/nanoc/regressions/gh_891_spec.rb +0 -28
  195. data/spec/nanoc/regressions/gh_913_spec.rb +0 -26
  196. data/spec/nanoc/regressions/gh_924_spec.rb +0 -91
  197. data/spec/nanoc/regressions/gh_928_spec.rb +0 -7
  198. data/spec/nanoc/regressions/gh_937_spec.rb +0 -27
  199. data/spec/nanoc/regressions/gh_942_spec.rb +0 -23
  200. data/spec/nanoc/regressions/gh_947_spec.rb +0 -23
  201. data/spec/nanoc/regressions/gh_948_spec.rb +0 -18
  202. data/spec/nanoc/regressions/gh_951_spec.rb +0 -21
  203. data/spec/nanoc/regressions/gh_954_spec.rb +0 -35
  204. data/spec/nanoc/regressions/gh_970a_spec.rb +0 -19
  205. data/spec/nanoc/regressions/gh_970b_spec.rb +0 -52
  206. data/spec/nanoc/regressions/gh_974_spec.rb +0 -19
  207. data/spec/nanoc/regressions/gh_981_spec.rb +0 -23
  208. data/spec/nanoc/rule_dsl/action_sequence_calculator_spec.rb +0 -230
  209. data/spec/nanoc/rule_dsl/recording_executor_spec.rb +0 -145
  210. data/spec/nanoc/rule_dsl/rule_context_spec.rb +0 -251
  211. data/spec/nanoc/rule_dsl/rule_spec.rb +0 -111
  212. data/spec/nanoc/rule_dsl/rules_collection_spec.rb +0 -301
  213. data/spec/nanoc/spec_spec.rb +0 -70
  214. data/spec/nanoc/telemetry/counter_spec.rb +0 -20
  215. data/spec/nanoc/telemetry/labelled_counter_spec.rb +0 -94
  216. data/spec/nanoc/telemetry/labelled_summary_spec.rb +0 -78
  217. data/spec/nanoc/telemetry/stopwatch_spec.rb +0 -63
  218. data/spec/nanoc/telemetry/summary_spec.rb +0 -68
  219. data/spec/nanoc/telemetry/table_spec.rb +0 -22
  220. data/spec/nanoc/telemetry_spec.rb +0 -28
  221. data/spec/regression_filenames_spec.rb +0 -18
  222. data/spec/spec_helper.rb +0 -371
  223. data/test/base/test_compiler.rb +0 -389
  224. data/test/base/test_filter.rb +0 -73
  225. data/test/base/test_site.rb +0 -146
  226. data/test/checking/checks/test_css.rb +0 -66
  227. data/test/checking/checks/test_external_links.rb +0 -88
  228. data/test/checking/checks/test_html.rb +0 -47
  229. data/test/checking/checks/test_internal_links.rb +0 -118
  230. data/test/checking/checks/test_mixed_content.rb +0 -190
  231. data/test/checking/checks/test_stale.rb +0 -69
  232. data/test/checking/test_check.rb +0 -22
  233. data/test/checking/test_dsl.rb +0 -35
  234. data/test/checking/test_runner.rb +0 -45
  235. data/test/cli/commands/test_check.rb +0 -20
  236. data/test/cli/commands/test_compile.rb +0 -199
  237. data/test/cli/commands/test_create_site.rb +0 -126
  238. data/test/cli/commands/test_help.rb +0 -10
  239. data/test/cli/commands/test_prune.rb +0 -157
  240. data/test/cli/test_cleaning_stream.rb +0 -97
  241. data/test/cli/test_cli.rb +0 -195
  242. data/test/cli/test_error_handler.rb +0 -102
  243. data/test/cli/test_logger.rb +0 -7
  244. data/test/data_sources/test_filesystem.rb +0 -1033
  245. data/test/data_sources/test_filesystem_tools.rb +0 -146
  246. data/test/deploying/test_fog.rb +0 -117
  247. data/test/deploying/test_git.rb +0 -263
  248. data/test/deploying/test_rsync.rb +0 -94
  249. data/test/extra/core_ext/test_time.rb +0 -17
  250. data/test/extra/test_link_collector.rb +0 -110
  251. data/test/extra/test_piper.rb +0 -48
  252. data/test/filters/colorize_syntax/test_coderay.rb +0 -247
  253. data/test/filters/colorize_syntax/test_common.rb +0 -109
  254. data/test/filters/colorize_syntax/test_pygmentize.rb +0 -39
  255. data/test/filters/colorize_syntax/test_pygments.rb +0 -21
  256. data/test/filters/colorize_syntax/test_simon.rb +0 -24
  257. data/test/filters/test_asciidoc.rb +0 -16
  258. data/test/filters/test_bluecloth.rb +0 -16
  259. data/test/filters/test_coffeescript.rb +0 -16
  260. data/test/filters/test_erb.rb +0 -107
  261. data/test/filters/test_erubi.rb +0 -75
  262. data/test/filters/test_erubis.rb +0 -76
  263. data/test/filters/test_haml.rb +0 -94
  264. data/test/filters/test_handlebars.rb +0 -61
  265. data/test/filters/test_kramdown.rb +0 -56
  266. data/test/filters/test_markaby.rb +0 -16
  267. data/test/filters/test_maruku.rb +0 -16
  268. data/test/filters/test_mustache.rb +0 -43
  269. data/test/filters/test_pandoc.rb +0 -47
  270. data/test/filters/test_rainpress.rb +0 -27
  271. data/test/filters/test_rdiscount.rb +0 -30
  272. data/test/filters/test_rdoc.rb +0 -14
  273. data/test/filters/test_redcarpet.rb +0 -111
  274. data/test/filters/test_redcloth.rb +0 -31
  275. data/test/filters/test_relativize_paths.rb +0 -887
  276. data/test/filters/test_rubypants.rb +0 -16
  277. data/test/filters/test_sass.rb +0 -315
  278. data/test/filters/test_slim.rb +0 -59
  279. data/test/filters/test_typogruby.rb +0 -18
  280. data/test/filters/test_uglify_js.rb +0 -30
  281. data/test/filters/test_xsl.rb +0 -192
  282. data/test/filters/test_yui_compressor.rb +0 -42
  283. data/test/fixtures/vcr_cassettes/css_run_error.yml +0 -70
  284. data/test/fixtures/vcr_cassettes/css_run_ok.yml +0 -60
  285. data/test/fixtures/vcr_cassettes/css_run_parse_error.yml +0 -70
  286. data/test/fixtures/vcr_cassettes/html_run_error.yml +0 -56
  287. data/test/fixtures/vcr_cassettes/html_run_ok.yml +0 -58
  288. data/test/helper.rb +0 -255
  289. data/test/helpers/test_blogging.rb +0 -684
  290. data/test/helpers/test_capturing.rb +0 -184
  291. data/test/helpers/test_link_to.rb +0 -57
  292. data/test/helpers/test_xml_sitemap.rb +0 -246
  293. data/test/rule_dsl/test_action_provider.rb +0 -80
  294. data/test/rule_dsl/test_compiler_dsl.rb +0 -448
  295. data/test/rule_dsl/test_rules_collection.rb +0 -93
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'helper'
4
-
5
- class Nanoc::Filters::RedClothTest < Nanoc::TestCase
6
- def test_filter
7
- if_have 'redcloth' do
8
- # Get filter
9
- filter = ::Nanoc::Filters::RedCloth.new
10
-
11
- # Run filter
12
- result = filter.setup_and_run('h1. Foo')
13
- assert_equal('<h1>Foo</h1>', result)
14
- end
15
- end
16
-
17
- def test_filter_with_options
18
- if_have 'redcloth' do
19
- # Get filter
20
- filter = ::Nanoc::Filters::RedCloth.new
21
-
22
- # Run filter without options
23
- result = filter.setup_and_run('I am a member of SPECTRE.')
24
- assert_equal('<p>I am a member of <span class="caps">SPECTRE</span>.</p>', result)
25
-
26
- # Run filter with options
27
- result = filter.setup_and_run('I am a member of SPECTRE.', no_span_caps: true)
28
- assert_equal('<p>I am a member of SPECTRE.</p>', result)
29
- end
30
- end
31
- end
@@ -1,887 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'helper'
4
-
5
- class Nanoc::Filters::RelativizePathsTest < Nanoc::TestCase
6
- def test_filter_html_with_double_quotes
7
- # Create filter with mock item
8
- filter = Nanoc::Filters::RelativizePaths.new
9
-
10
- # Mock item
11
- filter.instance_eval do
12
- @item_rep = Nanoc::Int::ItemRep.new(
13
- Nanoc::Int::Item.new(
14
- 'content',
15
- {},
16
- '/foo/bar/baz',
17
- ),
18
- :blah,
19
- )
20
- @item_rep.paths[:last] = ['/foo/bar/baz/']
21
- end
22
-
23
- # Set content
24
- raw_content = %(<a href="/foo">foo</a>)
25
- expected_content = %(<a href="../..">foo</a>)
26
-
27
- # Test
28
- actual_content = filter.setup_and_run(raw_content, type: :html)
29
- assert_equal(expected_content, actual_content)
30
- end
31
-
32
- def test_filter_html_with_single_quotes
33
- # Create filter with mock item
34
- filter = Nanoc::Filters::RelativizePaths.new
35
-
36
- # Mock item
37
- filter.instance_eval do
38
- @item_rep = Nanoc::Int::ItemRep.new(
39
- Nanoc::Int::Item.new(
40
- 'content',
41
- {},
42
- '/foo/bar/baz',
43
- ),
44
- :blah,
45
- )
46
- @item_rep.paths[:last] = ['/foo/bar/baz/']
47
- end
48
-
49
- # Set content
50
- raw_content = %(<a href='/foo'>foo</a>)
51
- expected_content = %(<a href="../..">foo</a>)
52
-
53
- # Test
54
- actual_content = filter.setup_and_run(raw_content, type: :html)
55
- assert_equal(expected_content, actual_content)
56
- end
57
-
58
- def test_filter_html_without_quotes
59
- # Create filter with mock item
60
- filter = Nanoc::Filters::RelativizePaths.new
61
-
62
- # Mock item
63
- filter.instance_eval do
64
- @item_rep = Nanoc::Int::ItemRep.new(
65
- Nanoc::Int::Item.new(
66
- 'content',
67
- {},
68
- '/foo/bar/baz',
69
- ),
70
- :blah,
71
- )
72
- @item_rep.paths[:last] = ['/foo/bar/baz/']
73
- end
74
-
75
- # Set content
76
- raw_content = %(<a href=/foo>foo</a>)
77
- expected_content = %(<a href="../..">foo</a>)
78
-
79
- # Test
80
- actual_content = filter.setup_and_run(raw_content, type: :html)
81
- assert_equal(expected_content, actual_content)
82
- end
83
-
84
- def test_filter_html_with_boilerplate
85
- # Create filter with mock item
86
- filter = Nanoc::Filters::RelativizePaths.new
87
-
88
- # Mock item
89
- filter.instance_eval do
90
- @item_rep = Nanoc::Int::ItemRep.new(
91
- Nanoc::Int::Item.new(
92
- 'content',
93
- {},
94
- '/foo/bar/baz',
95
- ),
96
- :blah,
97
- )
98
- @item_rep.paths[:last] = ['/foo/bar/baz/']
99
- end
100
-
101
- # Set content
102
- raw_content = <<~EOS
103
- <!DOCTYPE html>
104
- <html>
105
- <head>
106
- <title>Hello</title>
107
- </head>
108
- <body>
109
- <a href=/foo>foo</a>
110
- </body>
111
- </html>
112
- EOS
113
- expected0 = %r{<a href="\.\./\.\.">foo</a>}
114
- expected1 = %r{\A\s*<!DOCTYPE html\s*>\s*<html>\s*<head>(.|\s)*<title>Hello</title>\s*</head>\s*<body>\s*<a href="../..">foo</a>\s*</body>\s*</html>\s*\Z}m
115
-
116
- # Test
117
- actual_content = filter.setup_and_run(raw_content, type: :html)
118
- assert_match(expected0, actual_content)
119
- assert_match(expected1, actual_content)
120
- end
121
-
122
- def test_filter_html5_with_boilerplate
123
- # Create filter with mock item
124
- filter = Nanoc::Filters::RelativizePaths.new
125
-
126
- # Mock item
127
- filter.instance_eval do
128
- @item_rep = Nanoc::Int::ItemRep.new(
129
- Nanoc::Int::Item.new(
130
- 'content',
131
- {},
132
- '/foo/bar/baz',
133
- ),
134
- :blah,
135
- )
136
- @item_rep.paths[:last] = ['/foo/bar/baz/']
137
- end
138
-
139
- # Set content
140
- raw_content = <<~EOS
141
- <!DOCTYPE html>
142
- <html>
143
- <head>
144
- <title>Hello</title>
145
- </head>
146
- <body>
147
- <a href=/foo>foo</a>
148
- </body>
149
- </html>
150
- EOS
151
- expected0 = %r{<a href="\.\./\.\.">foo</a>}
152
- expected1 = %r{\A\s*<!DOCTYPE html\s*>\s*<html>\s*<head>\s*<title>Hello</title>\s*</head>\s*<body>\s*<a href="../..">foo</a>\s*</body>\s*</html>\s*\Z}m
153
-
154
- # Test
155
- actual_content = filter.setup_and_run(raw_content, type: :html5)
156
- assert_match(expected0, actual_content)
157
- assert_match(expected1, actual_content)
158
- end
159
-
160
- def test_filter_html_multiple
161
- # Create filter with mock item
162
- filter = Nanoc::Filters::RelativizePaths.new
163
-
164
- # Mock item
165
- filter.instance_eval do
166
- @item_rep = Nanoc::Int::ItemRep.new(
167
- Nanoc::Int::Item.new(
168
- 'content',
169
- {},
170
- '/foo/bar/baz',
171
- ),
172
- :blah,
173
- )
174
- @item_rep.paths[:last] = ['/foo/bar/baz/']
175
- end
176
-
177
- # Set content
178
- raw_content = %(<a href="/foo">foo</a> <a href="/bar">bar</a>)
179
- expected_content = %(<a href="../..">foo</a> <a href="../../../bar">bar</a>)
180
-
181
- # Test
182
- actual_content = filter.setup_and_run(raw_content, type: :html)
183
- assert_equal(expected_content, actual_content)
184
- end
185
-
186
- def test_filter_html_nested
187
- # Create filter with mock item
188
- filter = Nanoc::Filters::RelativizePaths.new
189
-
190
- # Mock item
191
- filter.instance_eval do
192
- @item_rep = Nanoc::Int::ItemRep.new(
193
- Nanoc::Int::Item.new(
194
- 'content',
195
- {},
196
- '/foo/bar/baz',
197
- ),
198
- :blah,
199
- )
200
- @item_rep.paths[:last] = ['/foo/bar/baz/']
201
- end
202
-
203
- # Set content
204
- raw_content = %(<a href="/"><img src="/bar.png" /></a>)
205
- expected_content = %(<a href="../../../"><img src="../../../bar.png"></a>)
206
-
207
- # Test
208
- actual_content = filter.setup_and_run(raw_content, type: :html)
209
- assert_equal(expected_content, actual_content)
210
- end
211
-
212
- def test_filter_html_outside_tag
213
- # Create filter with mock item
214
- filter = Nanoc::Filters::RelativizePaths.new
215
-
216
- # Mock item
217
- filter.instance_eval do
218
- @item_rep = Nanoc::Int::ItemRep.new(
219
- Nanoc::Int::Item.new(
220
- 'content',
221
- {},
222
- '/foo/bar/baz',
223
- ),
224
- :blah,
225
- )
226
- @item_rep.paths[:last] = ['/foo/bar/baz/']
227
- end
228
-
229
- # Set content
230
- raw_content = %(stuff href="/foo" more stuff)
231
- expected_content = %(stuff href="/foo" more stuff)
232
-
233
- # Test
234
- actual_content = filter.setup_and_run(raw_content, type: :html)
235
- assert_equal(expected_content, actual_content)
236
- end
237
-
238
- def test_filter_html_root
239
- # Create filter with mock item
240
- filter = Nanoc::Filters::RelativizePaths.new
241
-
242
- # Mock item
243
- filter.instance_eval do
244
- @item_rep = Nanoc::Int::ItemRep.new(
245
- Nanoc::Int::Item.new(
246
- 'content',
247
- {},
248
- '/foo/bar/baz',
249
- ),
250
- :blah,
251
- )
252
- @item_rep.paths[:last] = ['/woof/meow/']
253
- end
254
-
255
- # Set content
256
- raw_content = %(<a href="/">foo</a>)
257
- expected_content = %(<a href="../../">foo</a>)
258
-
259
- # Test
260
- actual_content = filter.setup_and_run(raw_content, type: :html)
261
- assert_equal(expected_content, actual_content)
262
- end
263
-
264
- def test_filter_html_network_path
265
- # Create filter with mock item
266
- filter = Nanoc::Filters::RelativizePaths.new
267
-
268
- # Mock item
269
- filter.instance_eval do
270
- @item_rep = Nanoc::Int::ItemRep.new(
271
- Nanoc::Int::Item.new(
272
- 'content',
273
- {},
274
- '/foo/bar/baz',
275
- ),
276
- :blah,
277
- )
278
- @item_rep.paths[:last] = ['/woof/meow/']
279
- end
280
-
281
- # Set content
282
- raw_content = %(<a href="//example.com/">example.com</a>)
283
- expected_content = %(<a href="//example.com/">example.com</a>)
284
-
285
- # Test
286
- actual_content = filter.setup_and_run(raw_content, type: :html)
287
- assert_equal(expected_content, actual_content)
288
- end
289
-
290
- def test_filter_html_with_anchor
291
- # Create filter with mock item
292
- filter = Nanoc::Filters::RelativizePaths.new
293
-
294
- # Mock item
295
- filter.instance_eval do
296
- @item_rep = Nanoc::Int::ItemRep.new(
297
- Nanoc::Int::Item.new(
298
- 'content',
299
- {},
300
- '/foo/bar/baz',
301
- ),
302
- :blah,
303
- )
304
- @item_rep.paths[:last] = ['/woof/meow/']
305
- end
306
-
307
- # Set content
308
- raw_content = %(<a href="#max-payne">Max Payne</a>)
309
- expected_content = %(<a href="#max-payne">Max Payne</a>)
310
-
311
- # Test
312
- actual_content = filter.setup_and_run(raw_content, type: :html)
313
- assert_equal(expected_content, actual_content)
314
- end
315
-
316
- def test_filter_html_with_url
317
- # Create filter with mock item
318
- filter = Nanoc::Filters::RelativizePaths.new
319
-
320
- # Mock item
321
- filter.instance_eval do
322
- @item_rep = Nanoc::Int::ItemRep.new(
323
- Nanoc::Int::Item.new(
324
- 'content',
325
- {},
326
- '/foo/bar/baz',
327
- ),
328
- :blah,
329
- )
330
- @item_rep.paths[:last] = ['/woof/meow/']
331
- end
332
-
333
- # Set content
334
- raw_content = %(<a href="http://example.com/">Example</a>)
335
- expected_content = %(<a href="http://example.com/">Example</a>)
336
-
337
- # Test
338
- actual_content = filter.setup_and_run(raw_content, type: :html)
339
- assert_equal(expected_content, actual_content)
340
- end
341
-
342
- def test_filter_html_with_relative_path
343
- # Create filter with mock item
344
- filter = Nanoc::Filters::RelativizePaths.new
345
-
346
- # Mock item
347
- filter.instance_eval do
348
- @item_rep = Nanoc::Int::ItemRep.new(
349
- Nanoc::Int::Item.new(
350
- 'content',
351
- {},
352
- '/foo/bar/baz',
353
- ),
354
- :blah,
355
- )
356
- @item_rep.paths[:last] = ['/woof/meow/']
357
- end
358
-
359
- # Set content
360
- raw_content = %(<a href="example">Example</a>)
361
- expected_content = %(<a href="example">Example</a>)
362
-
363
- # Test
364
- actual_content = filter.setup_and_run(raw_content, type: :html)
365
- assert_equal(expected_content, actual_content)
366
- end
367
-
368
- def test_filter_html_object_with_relative_path
369
- # Create filter with mock item
370
- filter = Nanoc::Filters::RelativizePaths.new
371
-
372
- # Mock item
373
- filter.instance_eval do
374
- @item_rep = Nanoc::Int::ItemRep.new(
375
- Nanoc::Int::Item.new(
376
- 'content',
377
- {},
378
- '/foo/bar/baz',
379
- ),
380
- :blah,
381
- )
382
- @item_rep.paths[:last] = ['/woof/meow/']
383
- end
384
-
385
- raw_content = %(<object data="/example"><param name="movie" content="/example"></object>)
386
- actual_content = filter.setup_and_run(raw_content, type: :html)
387
-
388
- assert_match(/<object data="..\/..\/example">/, actual_content)
389
- assert_match(/<param (name="movie" )?content="..\/..\/example"/, actual_content)
390
- end
391
-
392
- def test_filter_form
393
- # Create filter with mock item
394
- filter = Nanoc::Filters::RelativizePaths.new
395
-
396
- # Mock item
397
- filter.instance_eval do
398
- @item_rep = Nanoc::Int::ItemRep.new(
399
- Nanoc::Int::Item.new(
400
- 'content',
401
- {},
402
- '/foo/bar/baz',
403
- ),
404
- :blah,
405
- )
406
- @item_rep.paths[:last] = ['/foo/bar/baz/']
407
- end
408
-
409
- # Set content
410
- raw_content = %(<form action="/example"></form>)
411
- expected_content = %(<form action="../../../example"></form>)
412
-
413
- # Test
414
- actual_content = filter.setup_and_run(raw_content, type: :html)
415
- assert_equal(expected_content, actual_content)
416
- end
417
-
418
- def test_filter_implicit
419
- # Create filter with mock item
420
- filter = Nanoc::Filters::RelativizePaths.new
421
-
422
- # Test
423
- assert_raises(RuntimeError) do
424
- filter.setup_and_run('moo')
425
- end
426
- end
427
-
428
- def test_filter_css_with_double_quotes
429
- # Create filter with mock item
430
- filter = Nanoc::Filters::RelativizePaths.new
431
-
432
- # Mock item
433
- filter.instance_eval do
434
- @item_rep = Nanoc::Int::ItemRep.new(
435
- Nanoc::Int::Item.new(
436
- 'content',
437
- {},
438
- '/foo/bar/baz',
439
- ),
440
- :blah,
441
- )
442
- @item_rep.paths[:last] = ['/foo/bar/baz/']
443
- end
444
-
445
- # Set content
446
- raw_content = %[background: url("/foo/bar/background.png");]
447
- expected_content = %[background: url("../background.png");]
448
-
449
- # Test
450
- actual_content = filter.setup_and_run(raw_content, type: :css)
451
- assert_equal(expected_content, actual_content)
452
- end
453
-
454
- def test_filter_css_with_single_quotes
455
- # Create filter with mock item
456
- filter = Nanoc::Filters::RelativizePaths.new
457
-
458
- # Mock item
459
- filter.instance_eval do
460
- @item_rep = Nanoc::Int::ItemRep.new(
461
- Nanoc::Int::Item.new(
462
- 'content',
463
- {},
464
- '/foo/bar/baz',
465
- ),
466
- :blah,
467
- )
468
- @item_rep.paths[:last] = ['/foo/bar/baz/']
469
- end
470
-
471
- # Set content
472
- raw_content = %[background: url('/foo/bar/background.png');]
473
- expected_content = %[background: url('../background.png');]
474
-
475
- # Test
476
- actual_content = filter.setup_and_run(raw_content, type: :css)
477
- assert_equal(expected_content, actual_content)
478
- end
479
-
480
- def test_filter_css_without_quotes
481
- # Create filter with mock item
482
- filter = Nanoc::Filters::RelativizePaths.new
483
-
484
- # Mock item
485
- filter.instance_eval do
486
- @item_rep = Nanoc::Int::ItemRep.new(
487
- Nanoc::Int::Item.new(
488
- 'content',
489
- {},
490
- '/foo/bar/baz',
491
- ),
492
- :blah,
493
- )
494
- @item_rep.paths[:last] = ['/foo/bar/baz/']
495
- end
496
-
497
- # Set content
498
- raw_content = %[background: url(/foo/bar/background.png);]
499
- expected_content = %[background: url(../background.png);]
500
-
501
- # Test
502
- actual_content = filter.setup_and_run(raw_content, type: :css)
503
- assert_equal(expected_content, actual_content)
504
- end
505
-
506
- def test_filter_css_multiple
507
- # Create filter with mock item
508
- filter = Nanoc::Filters::RelativizePaths.new
509
-
510
- # Mock item
511
- filter.instance_eval do
512
- @item_rep = Nanoc::Int::ItemRep.new(
513
- Nanoc::Int::Item.new(
514
- 'content',
515
- {},
516
- '/foo/bar/baz',
517
- ),
518
- :blah,
519
- )
520
- @item_rep.paths[:last] = ['/foo/bar/baz/']
521
- end
522
-
523
- # Set content
524
- raw_content = %[background: url(/foo/bar/a.png) url(/foo/bar/b.png);]
525
- expected_content = %[background: url(../a.png) url(../b.png);]
526
-
527
- # Test
528
- actual_content = filter.setup_and_run(raw_content, type: :css)
529
- assert_equal(expected_content, actual_content)
530
- end
531
-
532
- def test_filter_css_root
533
- # It is probably a bit weird to have “url(/)” in CSS, but I’ve made a
534
- # test case for this situation anyway. Can’t hurt…
535
-
536
- # Create filter with mock item
537
- filter = Nanoc::Filters::RelativizePaths.new
538
-
539
- # Mock item
540
- filter.instance_eval do
541
- @item_rep = Nanoc::Int::ItemRep.new(
542
- Nanoc::Int::Item.new(
543
- 'content',
544
- {},
545
- '/foo/bar/baz',
546
- ),
547
- :blah,
548
- )
549
- @item_rep.paths[:last] = ['/woof/meow/']
550
- end
551
-
552
- # Set content
553
- raw_content = %[background: url(/);]
554
- expected_content = %[background: url(../../);]
555
-
556
- # Test
557
- actual_content = filter.setup_and_run(raw_content, type: :css)
558
- assert_equal(expected_content, actual_content)
559
- end
560
-
561
- def test_filter_css_network_path
562
- # Create filter with mock item
563
- filter = Nanoc::Filters::RelativizePaths.new
564
-
565
- # Mock item
566
- filter.instance_eval do
567
- @item_rep = Nanoc::Int::ItemRep.new(
568
- Nanoc::Int::Item.new(
569
- 'content',
570
- {},
571
- '/foo/bar/baz',
572
- ),
573
- :blah,
574
- )
575
- @item_rep.paths[:last] = ['/woof/meow/']
576
- end
577
-
578
- # Set content
579
- raw_content = %[background: url(//example.com);]
580
- expected_content = %[background: url(//example.com);]
581
-
582
- # Test
583
- actual_content = filter.setup_and_run(raw_content, type: :css)
584
- assert_equal(expected_content, actual_content)
585
- end
586
-
587
- def test_filter_xml
588
- if_have 'nokogiri' do
589
- # Create filter with mock item
590
- filter = Nanoc::Filters::RelativizePaths.new
591
-
592
- # Mock item
593
- filter.instance_eval do
594
- @item_rep = Nanoc::Int::ItemRep.new(
595
- Nanoc::Int::Item.new(
596
- 'content',
597
- {},
598
- '/foo/bar/baz',
599
- ),
600
- :blah,
601
- )
602
- @item_rep.paths[:last] = ['/foo/bar/baz/']
603
- end
604
-
605
- # Set content
606
- expected = /<bar boo="\.\.\/\.\.">baz<\/bar>/
607
- raw_content = <<~XML
608
- <?xml version="1.0" encoding="utf-8"?>
609
- <foo>
610
- <bar boo="/foo">baz</bar>
611
- </foo>
612
- XML
613
-
614
- actual_content = filter.setup_and_run(raw_content, type: :xml, select: ['*/@boo'])
615
-
616
- assert_match(expected, actual_content)
617
- end
618
- end
619
-
620
- def test_filter_fragment_xml
621
- if_have 'nokogiri' do
622
- # Create filter with mock item
623
- filter = Nanoc::Filters::RelativizePaths.new
624
-
625
- # Mock item
626
- filter.instance_eval do
627
- @item_rep = Nanoc::Int::ItemRep.new(
628
- Nanoc::Int::Item.new(
629
- 'content',
630
- {},
631
- '/foo/bar/baz',
632
- ),
633
- :blah,
634
- )
635
- @item_rep.paths[:last] = ['/foo/bar/baz/']
636
- end
637
-
638
- # Set content
639
- raw_content = <<~XML
640
- <foo>
641
- <bar><far href="/foo">baz</far></bar>
642
- </foo>
643
- XML
644
-
645
- actual_content = filter.setup_and_run(raw_content, type: :xml, select: ['far/@href'])
646
-
647
- assert_match(/<foo>/, actual_content)
648
- assert_match(/<bar><far href="..\/..">baz<\/far><\/bar>/, actual_content)
649
- end
650
- end
651
-
652
- def test_filter_xml_with_namespaces
653
- if_have 'nokogiri' do
654
- # Create filter with mock item
655
- filter = Nanoc::Filters::RelativizePaths.new
656
-
657
- # Mock item
658
- filter.instance_eval do
659
- @item_rep = Nanoc::Int::ItemRep.new(
660
- Nanoc::Int::Item.new(
661
- 'content',
662
- {},
663
- '/foo/bar/baz',
664
- ),
665
- :blah,
666
- )
667
- @item_rep.paths[:last] = ['/foo/bar/baz/']
668
- end
669
-
670
- # Set content
671
- raw_content = <<~XML
672
- <foo xmlns="http://example.org">
673
- <bar><a href="/foo">baz</a></bar>
674
- </foo>
675
- XML
676
-
677
- options = {
678
- type: :xml,
679
- namespaces: { ex: 'http://example.org' },
680
- select: ['ex:a/@href'],
681
- }
682
- actual_content = filter.setup_and_run(raw_content, options)
683
-
684
- assert_match(/<foo xmlns="http:\/\/example.org">/, actual_content)
685
- assert_match(/<bar><a href="..\/..">baz<\/a><\/bar>/, actual_content)
686
- end
687
- end
688
-
689
- def test_filter_xhtml
690
- if_have 'nokogiri' do
691
- # Create filter with mock item
692
- filter = Nanoc::Filters::RelativizePaths.new
693
-
694
- # Mock item
695
- filter.instance_eval do
696
- @item_rep = Nanoc::Int::ItemRep.new(
697
- Nanoc::Int::Item.new(
698
- 'content',
699
- {},
700
- '/foo/bar/baz',
701
- ),
702
- :blah,
703
- )
704
- @item_rep.paths[:last] = ['/foo/bar/baz/']
705
- end
706
-
707
- # Set content
708
- raw_content = <<~XML
709
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
710
- <html xmlns="http://www.w3.org/1999/xhtml">
711
- <head>
712
- <link rel="stylesheet" href="/css"/>
713
- <script src="/js"></script>
714
- </head>
715
- <body>
716
- <a href="/foo">bar</a>
717
- <img src="/img"/>
718
- </body>
719
- </html>
720
- XML
721
-
722
- actual_content = filter.setup_and_run(raw_content, type: :xhtml)
723
-
724
- assert_match(/<link[^>]*href="..\/..\/..\/css"[^>]*\/>/, actual_content)
725
- assert_match(/<script src="..\/..\/..\/js">/, actual_content)
726
- assert_match(/<img src="..\/..\/..\/img"[^>]*\/>/, actual_content)
727
- assert_match(/<a href="..\/..">bar<\/a>/, actual_content)
728
- end
729
- end
730
-
731
- def test_filter_fragment_xhtml
732
- if_have 'nokogiri' do
733
- # Create filter with mock item
734
- filter = Nanoc::Filters::RelativizePaths.new
735
-
736
- # Mock item
737
- filter.instance_eval do
738
- @item_rep = Nanoc::Int::ItemRep.new(
739
- Nanoc::Int::Item.new(
740
- 'content',
741
- {},
742
- '/foo/bar/baz',
743
- ),
744
- :blah,
745
- )
746
- @item_rep.paths[:last] = ['/foo/bar/baz/']
747
- end
748
-
749
- # Set content
750
- raw_content = <<~XML
751
- <a href="/foo">bar</a>
752
- <p>
753
- <img src="/img"/>
754
- </p>
755
- XML
756
-
757
- expected_content =
758
- %r{\A\s*<a href="../..">bar</a>\s*<p>\s*<img src="../../../img" />\s*</p>\s*\Z}m
759
-
760
- # Test
761
- actual_content = filter.setup_and_run(raw_content.freeze, type: :xhtml)
762
- assert_match(expected_content, actual_content)
763
- end
764
- end
765
-
766
- def test_filter_fragment_xhtml_with_comments
767
- if_have 'nokogiri' do
768
- # Create filter with mock item
769
- filter = Nanoc::Filters::RelativizePaths.new
770
-
771
- # Mock item
772
- filter.instance_eval do
773
- @item_rep = Nanoc::Int::ItemRep.new(
774
- Nanoc::Int::Item.new(
775
- 'content',
776
- {},
777
- '/foo/baz',
778
- ),
779
- :blah,
780
- )
781
- @item_rep.paths[:last] = ['/foo/baz/']
782
- end
783
-
784
- # Set content
785
- raw_content = %(
786
- <link rel="stylesheet" href="/foo.css" />
787
- <!--[if lt IE 9]>
788
- <script src="/js/lib/html5shiv.js"></script>
789
- <![endif]-->
790
-
791
- )
792
-
793
- actual_content = filter.setup_and_run(raw_content.freeze, type: :xhtml)
794
-
795
- assert_match(/<link (rel="stylesheet" )?href="..\/..\/foo.css" /, actual_content)
796
- assert_match(/<script src="..\/..\/js\/lib\/html5shiv.js"><\/script>/, actual_content)
797
- end
798
- end
799
-
800
- def test_filter_fragment_html_with_comments
801
- if_have 'nokogiri' do
802
- # Create filter with mock item
803
- filter = Nanoc::Filters::RelativizePaths.new
804
-
805
- # Mock item
806
- filter.instance_eval do
807
- @item_rep = Nanoc::Int::ItemRep.new(
808
- Nanoc::Int::Item.new(
809
- 'content',
810
- {},
811
- '/foo/baz',
812
- ),
813
- :blah,
814
- )
815
- @item_rep.paths[:last] = ['/foo/baz/']
816
- end
817
-
818
- # Set content
819
- raw_content = %(
820
- <!--[if lt IE 9]>
821
- <script src="/js/lib/html5shiv.js"></script>
822
- <![endif]-->
823
-
824
- )
825
-
826
- # Test
827
- actual_content = filter.setup_and_run(raw_content.freeze, type: :html)
828
- assert actual_content.include? %(<script src="../../js/lib/html5shiv.js">)
829
- end
830
- end
831
-
832
- def test_filter_html_doctype
833
- # Create filter with mock item
834
- filter = Nanoc::Filters::RelativizePaths.new
835
-
836
- # Mock item
837
- filter.instance_eval do
838
- @item_rep = Nanoc::Int::ItemRep.new(
839
- Nanoc::Int::Item.new(
840
- 'content',
841
- {},
842
- '/foo/bar/baz',
843
- ),
844
- :blah,
845
- )
846
- @item_rep.paths[:last] = ['/foo/bar/baz/']
847
- end
848
-
849
- # Set content
850
- raw_content = %(&lt;!DOCTYPE html>)
851
- expected_content = %(&lt;!DOCTYPE html&gt;)
852
-
853
- # Test
854
- actual_content = filter.setup_and_run(raw_content, type: :html)
855
- assert_equal(expected_content, actual_content)
856
- end
857
-
858
- def test_filter_nokogiri_save_with
859
- if_have 'nokogiri' do
860
- # Create filter with mock item
861
- filter = Nanoc::Filters::RelativizePaths.new
862
-
863
- # Mock item
864
- filter.instance_eval do
865
- @item_rep = Nanoc::Int::ItemRep.new(
866
- Nanoc::Int::Item.new(
867
- 'content',
868
- {},
869
- '/foo/baz',
870
- ),
871
- :blah,
872
- )
873
- @item_rep.paths[:last] = ['/foo/baz/']
874
- end
875
-
876
- # Set content
877
- raw_content = %(
878
- <td><span>some</span><span>moderately</span><span>long</span><span>content</span></td>
879
- )
880
-
881
- # Test
882
- nokogiri_save_options = Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML & ~Nokogiri::XML::Node::SaveOptions::FORMAT
883
- actual_content = filter.setup_and_run(raw_content.freeze, type: :html, nokogiri_save_options: nokogiri_save_options)
884
- assert_equal(actual_content, raw_content)
885
- end
886
- end
887
- end