nanoc 3.2.4 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/ChangeLog +3 -0
- data/Gemfile +32 -0
- data/LICENSE +19 -0
- data/NEWS.md +470 -0
- data/README.md +114 -0
- data/Rakefile +14 -0
- data/bin/nanoc +7 -27
- data/bin/nanoc3 +3 -0
- data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
- data/lib/nanoc.rb +41 -0
- data/lib/nanoc/base.rb +49 -0
- data/lib/nanoc/base/compilation/checksum_store.rb +57 -0
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +62 -0
- data/lib/nanoc/base/compilation/compiler.rb +458 -0
- data/lib/nanoc/base/compilation/compiler_dsl.rb +214 -0
- data/lib/nanoc/base/compilation/dependency_tracker.rb +200 -0
- data/lib/nanoc/base/compilation/filter.rb +165 -0
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +103 -0
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +102 -0
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +223 -0
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +46 -0
- data/lib/nanoc/base/compilation/rule.rb +73 -0
- data/lib/nanoc/base/compilation/rule_context.rb +84 -0
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +40 -0
- data/lib/nanoc/base/compilation/rule_memory_store.rb +53 -0
- data/lib/nanoc/base/compilation/rules_collection.rb +243 -0
- data/lib/nanoc/base/context.rb +47 -0
- data/lib/nanoc/base/core_ext.rb +6 -0
- data/lib/nanoc/base/core_ext/array.rb +62 -0
- data/lib/nanoc/base/core_ext/hash.rb +63 -0
- data/lib/nanoc/base/core_ext/pathname.rb +26 -0
- data/lib/nanoc/base/core_ext/string.rb +46 -0
- data/lib/nanoc/base/directed_graph.rb +275 -0
- data/lib/nanoc/base/errors.rb +211 -0
- data/lib/nanoc/base/memoization.rb +67 -0
- data/lib/nanoc/base/notification_center.rb +84 -0
- data/lib/nanoc/base/ordered_hash.rb +200 -0
- data/lib/nanoc/base/plugin_registry.rb +181 -0
- data/lib/nanoc/base/result_data/item_rep.rb +492 -0
- data/lib/nanoc/base/source_data/code_snippet.rb +58 -0
- data/lib/nanoc/base/source_data/configuration.rb +24 -0
- data/lib/nanoc/base/source_data/data_source.rb +234 -0
- data/lib/nanoc/base/source_data/item.rb +301 -0
- data/lib/nanoc/base/source_data/layout.rb +130 -0
- data/lib/nanoc/base/source_data/site.rb +361 -0
- data/lib/nanoc/base/store.rb +135 -0
- data/lib/nanoc/cli.rb +137 -0
- data/lib/nanoc/cli/command_runner.rb +104 -0
- data/lib/nanoc/cli/commands/autocompile.rb +58 -0
- data/lib/nanoc/cli/commands/compile.rb +297 -0
- data/lib/nanoc/cli/commands/create_item.rb +60 -0
- data/lib/nanoc/cli/commands/create_layout.rb +73 -0
- data/lib/nanoc/cli/commands/create_site.rb +411 -0
- data/lib/nanoc/cli/commands/debug.rb +117 -0
- data/lib/nanoc/cli/commands/deploy.rb +79 -0
- data/lib/nanoc/cli/commands/info.rb +98 -0
- data/lib/nanoc/cli/commands/nanoc.rb +38 -0
- data/lib/nanoc/cli/commands/prune.rb +50 -0
- data/lib/nanoc/cli/commands/update.rb +70 -0
- data/lib/nanoc/cli/commands/view.rb +82 -0
- data/lib/nanoc/cli/commands/watch.rb +124 -0
- data/lib/nanoc/cli/error_handler.rb +199 -0
- data/lib/nanoc/cli/logger.rb +92 -0
- data/lib/nanoc/data_sources.rb +29 -0
- data/lib/nanoc/data_sources/deprecated/delicious.rb +42 -0
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +87 -0
- data/lib/nanoc/data_sources/deprecated/twitter.rb +38 -0
- data/lib/nanoc/data_sources/filesystem.rb +299 -0
- data/lib/nanoc/data_sources/filesystem_unified.rb +121 -0
- data/lib/nanoc/data_sources/filesystem_verbose.rb +91 -0
- data/lib/nanoc/extra.rb +24 -0
- data/lib/nanoc/extra/auto_compiler.rb +103 -0
- data/lib/nanoc/extra/chick.rb +125 -0
- data/lib/nanoc/extra/core_ext.rb +6 -0
- data/lib/nanoc/extra/core_ext/enumerable.rb +33 -0
- data/lib/nanoc/extra/core_ext/pathname.rb +30 -0
- data/lib/nanoc/extra/core_ext/time.rb +19 -0
- data/lib/nanoc/extra/deployer.rb +47 -0
- data/lib/nanoc/extra/deployers.rb +15 -0
- data/lib/nanoc/extra/deployers/fog.rb +98 -0
- data/lib/nanoc/extra/deployers/rsync.rb +70 -0
- data/lib/nanoc/extra/file_proxy.rb +40 -0
- data/lib/nanoc/extra/pruner.rb +86 -0
- data/lib/nanoc/extra/validators.rb +12 -0
- data/lib/nanoc/extra/validators/links.rb +268 -0
- data/lib/nanoc/extra/validators/w3c.rb +95 -0
- data/lib/nanoc/extra/vcs.rb +66 -0
- data/lib/nanoc/extra/vcses.rb +17 -0
- data/lib/nanoc/extra/vcses/bazaar.rb +25 -0
- data/lib/nanoc/extra/vcses/dummy.rb +24 -0
- data/lib/nanoc/extra/vcses/git.rb +25 -0
- data/lib/nanoc/extra/vcses/mercurial.rb +25 -0
- data/lib/nanoc/extra/vcses/subversion.rb +25 -0
- data/lib/nanoc/filters.rb +59 -0
- data/lib/nanoc/filters/asciidoc.rb +38 -0
- data/lib/nanoc/filters/bluecloth.rb +19 -0
- data/lib/nanoc/filters/coderay.rb +21 -0
- data/lib/nanoc/filters/coffeescript.rb +20 -0
- data/lib/nanoc/filters/colorize_syntax.rb +298 -0
- data/lib/nanoc/filters/erb.rb +38 -0
- data/lib/nanoc/filters/erubis.rb +34 -0
- data/lib/nanoc/filters/haml.rb +27 -0
- data/lib/nanoc/filters/kramdown.rb +20 -0
- data/lib/nanoc/filters/less.rb +53 -0
- data/lib/nanoc/filters/markaby.rb +20 -0
- data/lib/nanoc/filters/maruku.rb +20 -0
- data/lib/nanoc/filters/mustache.rb +24 -0
- data/lib/nanoc/filters/rainpress.rb +19 -0
- data/lib/nanoc/filters/rdiscount.rb +22 -0
- data/lib/nanoc/filters/rdoc.rb +33 -0
- data/lib/nanoc/filters/redcarpet.rb +62 -0
- data/lib/nanoc/filters/redcloth.rb +47 -0
- data/lib/nanoc/filters/relativize_paths.rb +94 -0
- data/lib/nanoc/filters/rubypants.rb +20 -0
- data/lib/nanoc/filters/sass.rb +74 -0
- data/lib/nanoc/filters/slim.rb +25 -0
- data/lib/nanoc/filters/typogruby.rb +23 -0
- data/lib/nanoc/filters/uglify_js.rb +42 -0
- data/lib/nanoc/filters/xsl.rb +46 -0
- data/lib/nanoc/filters/yui_compressor.rb +23 -0
- data/lib/nanoc/helpers.rb +16 -0
- data/lib/nanoc/helpers/blogging.rb +319 -0
- data/lib/nanoc/helpers/breadcrumbs.rb +40 -0
- data/lib/nanoc/helpers/capturing.rb +138 -0
- data/lib/nanoc/helpers/filtering.rb +50 -0
- data/lib/nanoc/helpers/html_escape.rb +55 -0
- data/lib/nanoc/helpers/link_to.rb +151 -0
- data/lib/nanoc/helpers/rendering.rb +140 -0
- data/lib/nanoc/helpers/tagging.rb +71 -0
- data/lib/nanoc/helpers/text.rb +44 -0
- data/lib/nanoc/helpers/xml_sitemap.rb +76 -0
- data/lib/nanoc/tasks.rb +10 -0
- data/lib/nanoc/tasks/clean.rake +16 -0
- data/lib/nanoc/tasks/clean.rb +29 -0
- data/lib/nanoc/tasks/deploy/rsync.rake +16 -0
- data/lib/nanoc/tasks/validate.rake +92 -0
- data/nanoc.gemspec +49 -0
- data/tasks/doc.rake +16 -0
- data/tasks/test.rake +46 -0
- data/test/base/core_ext/array_spec.rb +73 -0
- data/test/base/core_ext/hash_spec.rb +98 -0
- data/test/base/core_ext/pathname_spec.rb +27 -0
- data/test/base/core_ext/string_spec.rb +37 -0
- data/test/base/test_checksum_store.rb +35 -0
- data/test/base/test_code_snippet.rb +31 -0
- data/test/base/test_compiler.rb +403 -0
- data/test/base/test_compiler_dsl.rb +161 -0
- data/test/base/test_context.rb +31 -0
- data/test/base/test_data_source.rb +46 -0
- data/test/base/test_dependency_tracker.rb +262 -0
- data/test/base/test_directed_graph.rb +288 -0
- data/test/base/test_filter.rb +83 -0
- data/test/base/test_item.rb +179 -0
- data/test/base/test_item_rep.rb +579 -0
- data/test/base/test_layout.rb +59 -0
- data/test/base/test_memoization.rb +90 -0
- data/test/base/test_notification_center.rb +34 -0
- data/test/base/test_outdatedness_checker.rb +394 -0
- data/test/base/test_plugin.rb +30 -0
- data/test/base/test_rule.rb +19 -0
- data/test/base/test_rule_context.rb +65 -0
- data/test/base/test_site.rb +190 -0
- data/test/cli/commands/test_compile.rb +33 -0
- data/test/cli/commands/test_create_item.rb +14 -0
- data/test/cli/commands/test_create_layout.rb +28 -0
- data/test/cli/commands/test_create_site.rb +24 -0
- data/test/cli/commands/test_deploy.rb +74 -0
- data/test/cli/commands/test_help.rb +12 -0
- data/test/cli/commands/test_info.rb +11 -0
- data/test/cli/commands/test_prune.rb +98 -0
- data/test/cli/commands/test_update.rb +10 -0
- data/test/cli/test_cli.rb +102 -0
- data/test/cli/test_error_handler.rb +29 -0
- data/test/cli/test_logger.rb +10 -0
- data/test/data_sources/test_filesystem.rb +433 -0
- data/test/data_sources/test_filesystem_unified.rb +536 -0
- data/test/data_sources/test_filesystem_verbose.rb +357 -0
- data/test/extra/core_ext/test_enumerable.rb +30 -0
- data/test/extra/core_ext/test_pathname.rb +17 -0
- data/test/extra/core_ext/test_time.rb +15 -0
- data/test/extra/deployers/test_fog.rb +67 -0
- data/test/extra/deployers/test_rsync.rb +100 -0
- data/test/extra/test_auto_compiler.rb +417 -0
- data/test/extra/test_file_proxy.rb +19 -0
- data/test/extra/test_vcs.rb +22 -0
- data/test/extra/validators/test_links.rb +62 -0
- data/test/extra/validators/test_w3c.rb +47 -0
- data/test/filters/test_asciidoc.rb +22 -0
- data/test/filters/test_bluecloth.rb +18 -0
- data/test/filters/test_coderay.rb +44 -0
- data/test/filters/test_coffeescript.rb +18 -0
- data/test/filters/test_colorize_syntax.rb +379 -0
- data/test/filters/test_erb.rb +105 -0
- data/test/filters/test_erubis.rb +78 -0
- data/test/filters/test_haml.rb +96 -0
- data/test/filters/test_kramdown.rb +18 -0
- data/test/filters/test_less.rb +113 -0
- data/test/filters/test_markaby.rb +24 -0
- data/test/filters/test_maruku.rb +18 -0
- data/test/filters/test_mustache.rb +25 -0
- data/test/filters/test_rainpress.rb +29 -0
- data/test/filters/test_rdiscount.rb +31 -0
- data/test/filters/test_rdoc.rb +18 -0
- data/test/filters/test_redcarpet.rb +73 -0
- data/test/filters/test_redcloth.rb +33 -0
- data/test/filters/test_relativize_paths.rb +533 -0
- data/test/filters/test_rubypants.rb +18 -0
- data/test/filters/test_sass.rb +229 -0
- data/test/filters/test_slim.rb +35 -0
- data/test/filters/test_typogruby.rb +21 -0
- data/test/filters/test_uglify_js.rb +30 -0
- data/test/filters/test_xsl.rb +105 -0
- data/test/filters/test_yui_compressor.rb +44 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +207 -0
- data/test/helpers/test_blogging.rb +754 -0
- data/test/helpers/test_breadcrumbs.rb +81 -0
- data/test/helpers/test_capturing.rb +41 -0
- data/test/helpers/test_filtering.rb +106 -0
- data/test/helpers/test_html_escape.rb +32 -0
- data/test/helpers/test_link_to.rb +249 -0
- data/test/helpers/test_rendering.rb +89 -0
- data/test/helpers/test_tagging.rb +87 -0
- data/test/helpers/test_text.rb +24 -0
- data/test/helpers/test_xml_sitemap.rb +103 -0
- data/test/tasks/test_clean.rb +67 -0
- metadata +327 -15
- data/bin/nanoc-select +0 -86
- data/lib/nanoc-select.rb +0 -11
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::MustacheTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'mustache' do
|
|
9
|
+
# Create item
|
|
10
|
+
item = Nanoc::Item.new(
|
|
11
|
+
'content',
|
|
12
|
+
{ :title => 'Max Payne', :protagonist => 'Max Payne' },
|
|
13
|
+
'/games/max-payne/'
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# Create filter
|
|
17
|
+
filter = ::Nanoc::Filters::Mustache.new({ :item => item })
|
|
18
|
+
|
|
19
|
+
# Run filter
|
|
20
|
+
result = filter.run('The protagonist of {{title}} is {{protagonist}}.')
|
|
21
|
+
assert_equal('The protagonist of Max Payne is Max Payne.', result)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::RainpressTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'rainpress' do
|
|
9
|
+
# Create filter
|
|
10
|
+
filter = ::Nanoc::Filters::Rainpress.new
|
|
11
|
+
|
|
12
|
+
# Run filter
|
|
13
|
+
result = filter.run("body { color: black; }")
|
|
14
|
+
assert_equal("body{color:#000}", result)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_filter_with_options
|
|
19
|
+
if_have 'rainpress' do
|
|
20
|
+
# Create filter
|
|
21
|
+
filter = ::Nanoc::Filters::Rainpress.new
|
|
22
|
+
|
|
23
|
+
# Run filter
|
|
24
|
+
result = filter.run("body { color: #aabbcc; }", :colors => false)
|
|
25
|
+
assert_equal("body{color:#aabbcc}", result)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::RDiscountTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'rdiscount' do
|
|
9
|
+
# Create filter
|
|
10
|
+
filter = ::Nanoc::Filters::RDiscount.new
|
|
11
|
+
|
|
12
|
+
# Run filter
|
|
13
|
+
result = filter.run("> Quote")
|
|
14
|
+
assert_match(/<blockquote>\s*<p>Quote<\/p>\s*<\/blockquote>/, result)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_with_extensions
|
|
19
|
+
if_have 'rdiscount' do
|
|
20
|
+
# Create filter
|
|
21
|
+
filter = ::Nanoc::Filters::RDiscount.new
|
|
22
|
+
|
|
23
|
+
# Run filter
|
|
24
|
+
input = "The quotation 'marks' sure make this look sarcastic!"
|
|
25
|
+
output_expected = /The quotation ‘marks’ sure make this look sarcastic!/
|
|
26
|
+
output_actual = filter.run(input, :extensions => [ :smart ])
|
|
27
|
+
assert_match(output_expected, output_actual)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::RDocTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'rdoc' do
|
|
9
|
+
# Get filter
|
|
10
|
+
filter = ::Nanoc::Filters::RDoc.new
|
|
11
|
+
|
|
12
|
+
# Run filter
|
|
13
|
+
result = filter.run("= Foo")
|
|
14
|
+
assert_match(%r{<h1( id="label-Foo")?>Foo</h1>\Z}, result)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::RedcarpetTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_find
|
|
8
|
+
if_have 'redcarpet' do
|
|
9
|
+
refute Nanoc::Filter.named(:redcarpet).nil?
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_filter
|
|
14
|
+
if_have 'redcarpet' do
|
|
15
|
+
# Create filter
|
|
16
|
+
filter = ::Nanoc::Filters::Redcarpet.new
|
|
17
|
+
|
|
18
|
+
# Run filter
|
|
19
|
+
result = filter.run("> Quote")
|
|
20
|
+
assert_match(/<blockquote>\s*<p>Quote<\/p>\s*<\/blockquote>/, result)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_with_extensions
|
|
25
|
+
if_have 'redcarpet' do
|
|
26
|
+
# Create filter
|
|
27
|
+
filter = ::Nanoc::Filters::Redcarpet.new
|
|
28
|
+
|
|
29
|
+
# Run filter
|
|
30
|
+
if ::Redcarpet::VERSION > '2'
|
|
31
|
+
input = "this is ~~good~~ bad"
|
|
32
|
+
output_expected = /this is <del>good<\/del> bad/
|
|
33
|
+
output_actual = filter.run(input, :options => { :strikethrough => true })
|
|
34
|
+
else
|
|
35
|
+
input = "The quotation 'marks' sure make this look sarcastic!"
|
|
36
|
+
output_expected = /The quotation ‘marks’ sure make this look sarcastic!/
|
|
37
|
+
output_actual = filter.run(input, :options => [ :smart ])
|
|
38
|
+
end
|
|
39
|
+
assert_match(output_expected, output_actual)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_html_by_default
|
|
44
|
+
if_have 'redcarpet' do
|
|
45
|
+
# Create filter
|
|
46
|
+
filter = ::Nanoc::Filters::Redcarpet.new
|
|
47
|
+
|
|
48
|
+
# Run filter
|
|
49
|
+
input = ""
|
|
50
|
+
output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title">}
|
|
51
|
+
output_actual = filter.run(input)
|
|
52
|
+
assert_match(output_expected, output_actual)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_xhtml_if_requested
|
|
57
|
+
if_have 'redcarpet' do
|
|
58
|
+
# Create filter
|
|
59
|
+
filter = ::Nanoc::Filters::Redcarpet.new
|
|
60
|
+
|
|
61
|
+
# Run filter
|
|
62
|
+
input = ""
|
|
63
|
+
output_expected = %r{<img src="/path/to/img" alt="Alt" title="Title"/>}
|
|
64
|
+
if ::Redcarpet::VERSION > '2'
|
|
65
|
+
output_actual = filter.run(input, :renderer_options => { :xhtml => true })
|
|
66
|
+
else
|
|
67
|
+
output_actual = filter.run(input, :options => [ :xhtml ])
|
|
68
|
+
end
|
|
69
|
+
assert_match(output_expected, output_actual)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::RedClothTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
def test_filter
|
|
8
|
+
if_have 'redcloth' do
|
|
9
|
+
# Get filter
|
|
10
|
+
filter = ::Nanoc::Filters::RedCloth.new
|
|
11
|
+
|
|
12
|
+
# Run filter
|
|
13
|
+
result = filter.run("h1. Foo")
|
|
14
|
+
assert_equal("<h1>Foo</h1>", result)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_filter_with_options
|
|
19
|
+
if_have 'redcloth' do
|
|
20
|
+
# Get filter
|
|
21
|
+
filter = ::Nanoc::Filters::RedCloth.new
|
|
22
|
+
|
|
23
|
+
# Run filter without options
|
|
24
|
+
result = filter.run("I am a member of SPECTRE.")
|
|
25
|
+
assert_equal("<p>I am a member of <span class=\"caps\">SPECTRE</span>.</p>", result)
|
|
26
|
+
|
|
27
|
+
# Run filter with options
|
|
28
|
+
result = filter.run("I am a member of SPECTRE.", :no_span_caps => true)
|
|
29
|
+
assert_equal("<p>I am a member of SPECTRE.</p>", result)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
class Nanoc::Filters::RelativizePathsTest < MiniTest::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
include Nanoc::TestHelpers
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_filter_html_with_double_quotes
|
|
9
|
+
# Create filter with mock item
|
|
10
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
11
|
+
|
|
12
|
+
# Mock item
|
|
13
|
+
filter.instance_eval do
|
|
14
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
15
|
+
Nanoc::Item.new(
|
|
16
|
+
'content',
|
|
17
|
+
{},
|
|
18
|
+
'/foo/bar/baz/'),
|
|
19
|
+
:blah)
|
|
20
|
+
@item_rep.path = '/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.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::ItemRep.new(
|
|
39
|
+
Nanoc::Item.new(
|
|
40
|
+
'content',
|
|
41
|
+
{},
|
|
42
|
+
'/foo/bar/baz/'),
|
|
43
|
+
:blah)
|
|
44
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Set content
|
|
48
|
+
raw_content = %[<a href='/foo'>foo</a>]
|
|
49
|
+
expected_content = %[<a href='../..'>foo</a>]
|
|
50
|
+
|
|
51
|
+
# Test
|
|
52
|
+
actual_content = filter.run(raw_content, :type => :html)
|
|
53
|
+
assert_equal(expected_content, actual_content)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_filter_html_without_quotes
|
|
57
|
+
# Create filter with mock item
|
|
58
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
59
|
+
|
|
60
|
+
# Mock item
|
|
61
|
+
filter.instance_eval do
|
|
62
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
63
|
+
Nanoc::Item.new(
|
|
64
|
+
'content',
|
|
65
|
+
{},
|
|
66
|
+
'/foo/bar/baz/'),
|
|
67
|
+
:blah)
|
|
68
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Set content
|
|
72
|
+
raw_content = %[<a href=/foo>foo</a>]
|
|
73
|
+
expected_content = %[<a href=../..>foo</a>]
|
|
74
|
+
|
|
75
|
+
# Test
|
|
76
|
+
actual_content = filter.run(raw_content, :type => :html)
|
|
77
|
+
assert_equal(expected_content, actual_content)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_filter_html_multiple
|
|
81
|
+
# Create filter with mock item
|
|
82
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
83
|
+
|
|
84
|
+
# Mock item
|
|
85
|
+
filter.instance_eval do
|
|
86
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
87
|
+
Nanoc::Item.new(
|
|
88
|
+
'content',
|
|
89
|
+
{},
|
|
90
|
+
'/foo/bar/baz/'),
|
|
91
|
+
:blah)
|
|
92
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Set content
|
|
96
|
+
raw_content = %[<a href="/foo">foo</a> <a href="/bar">bar</a>]
|
|
97
|
+
expected_content = %[<a href="../..">foo</a> <a href="../../../bar">bar</a>]
|
|
98
|
+
|
|
99
|
+
# Test
|
|
100
|
+
actual_content = filter.run(raw_content, :type => :html)
|
|
101
|
+
assert_equal(expected_content, actual_content)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_filter_html_outside_tag
|
|
105
|
+
# Create filter with mock item
|
|
106
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
107
|
+
|
|
108
|
+
# Mock item
|
|
109
|
+
filter.instance_eval do
|
|
110
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
111
|
+
Nanoc::Item.new(
|
|
112
|
+
'content',
|
|
113
|
+
{},
|
|
114
|
+
'/foo/bar/baz/'),
|
|
115
|
+
:blah)
|
|
116
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Set content
|
|
120
|
+
raw_content = %[stuff href="/foo" more stuff]
|
|
121
|
+
expected_content = %[stuff href="/foo" more stuff]
|
|
122
|
+
|
|
123
|
+
# Test
|
|
124
|
+
actual_content = filter.run(raw_content, :type => :html)
|
|
125
|
+
assert_equal(expected_content, actual_content)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_filter_html_root
|
|
129
|
+
# Create filter with mock item
|
|
130
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
131
|
+
|
|
132
|
+
# Mock item
|
|
133
|
+
filter.instance_eval do
|
|
134
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
135
|
+
Nanoc::Item.new(
|
|
136
|
+
'content',
|
|
137
|
+
{},
|
|
138
|
+
'/foo/bar/baz/'),
|
|
139
|
+
:blah)
|
|
140
|
+
@item_rep.path = '/woof/meow/'
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Set content
|
|
144
|
+
raw_content = %[<a href="/">foo</a>]
|
|
145
|
+
expected_content = %[<a href="../../">foo</a>]
|
|
146
|
+
|
|
147
|
+
# Test
|
|
148
|
+
actual_content = filter.run(raw_content, :type => :html)
|
|
149
|
+
assert_equal(expected_content, actual_content)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def test_filter_html_network_path
|
|
153
|
+
# Create filter with mock item
|
|
154
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
155
|
+
|
|
156
|
+
# Mock item
|
|
157
|
+
filter.instance_eval do
|
|
158
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
159
|
+
Nanoc::Item.new(
|
|
160
|
+
'content',
|
|
161
|
+
{},
|
|
162
|
+
'/foo/bar/baz/'),
|
|
163
|
+
:blah)
|
|
164
|
+
@item_rep.path = '/woof/meow/'
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Set content
|
|
168
|
+
raw_content = %[<a href="//example.com/">example.com</a>]
|
|
169
|
+
expected_content = %[<a href="//example.com/">example.com</a>]
|
|
170
|
+
|
|
171
|
+
# Test
|
|
172
|
+
actual_content = filter.run(raw_content, :type => :html)
|
|
173
|
+
assert_equal(expected_content, actual_content)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def test_filter_implicit
|
|
177
|
+
# Create filter with mock item
|
|
178
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
179
|
+
|
|
180
|
+
# Test
|
|
181
|
+
assert_raises(RuntimeError) do
|
|
182
|
+
filter.run("moo")
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def test_filter_css_with_double_quotes
|
|
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::ItemRep.new(
|
|
193
|
+
Nanoc::Item.new(
|
|
194
|
+
'content',
|
|
195
|
+
{},
|
|
196
|
+
'/foo/bar/baz/'),
|
|
197
|
+
:blah)
|
|
198
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Set content
|
|
202
|
+
raw_content = %[background: url("/foo/bar/background.png");]
|
|
203
|
+
expected_content = %[background: url("../background.png");]
|
|
204
|
+
|
|
205
|
+
# Test
|
|
206
|
+
actual_content = filter.run(raw_content, :type => :css)
|
|
207
|
+
assert_equal(expected_content, actual_content)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def test_filter_css_with_single_quotes
|
|
211
|
+
# Create filter with mock item
|
|
212
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
213
|
+
|
|
214
|
+
# Mock item
|
|
215
|
+
filter.instance_eval do
|
|
216
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
217
|
+
Nanoc::Item.new(
|
|
218
|
+
'content',
|
|
219
|
+
{},
|
|
220
|
+
'/foo/bar/baz/'),
|
|
221
|
+
:blah)
|
|
222
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Set content
|
|
226
|
+
raw_content = %[background: url('/foo/bar/background.png');]
|
|
227
|
+
expected_content = %[background: url('../background.png');]
|
|
228
|
+
|
|
229
|
+
# Test
|
|
230
|
+
actual_content = filter.run(raw_content, :type => :css)
|
|
231
|
+
assert_equal(expected_content, actual_content)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def test_filter_css_without_quotes
|
|
235
|
+
# Create filter with mock item
|
|
236
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
237
|
+
|
|
238
|
+
# Mock item
|
|
239
|
+
filter.instance_eval do
|
|
240
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
241
|
+
Nanoc::Item.new(
|
|
242
|
+
'content',
|
|
243
|
+
{},
|
|
244
|
+
'/foo/bar/baz/'),
|
|
245
|
+
:blah)
|
|
246
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Set content
|
|
250
|
+
raw_content = %[background: url(/foo/bar/background.png);]
|
|
251
|
+
expected_content = %[background: url(../background.png);]
|
|
252
|
+
|
|
253
|
+
# Test
|
|
254
|
+
actual_content = filter.run(raw_content, :type => :css)
|
|
255
|
+
assert_equal(expected_content, actual_content)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def test_filter_css_multiple
|
|
259
|
+
# Create filter with mock item
|
|
260
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
261
|
+
|
|
262
|
+
# Mock item
|
|
263
|
+
filter.instance_eval do
|
|
264
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
265
|
+
Nanoc::Item.new(
|
|
266
|
+
'content',
|
|
267
|
+
{},
|
|
268
|
+
'/foo/bar/baz/'),
|
|
269
|
+
:blah)
|
|
270
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# Set content
|
|
274
|
+
raw_content = %[background: url(/foo/bar/a.png) url(/foo/bar/b.png);]
|
|
275
|
+
expected_content = %[background: url(../a.png) url(../b.png);]
|
|
276
|
+
|
|
277
|
+
# Test
|
|
278
|
+
actual_content = filter.run(raw_content, :type => :css)
|
|
279
|
+
assert_equal(expected_content, actual_content)
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def test_filter_css_root
|
|
283
|
+
# It is probably a bit weird to have “url(/)” in CSS, but I’ve made a
|
|
284
|
+
# test case for this situation anyway. Can’t hurt…
|
|
285
|
+
|
|
286
|
+
# Create filter with mock item
|
|
287
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
288
|
+
|
|
289
|
+
# Mock item
|
|
290
|
+
filter.instance_eval do
|
|
291
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
292
|
+
Nanoc::Item.new(
|
|
293
|
+
'content',
|
|
294
|
+
{},
|
|
295
|
+
'/foo/bar/baz/'),
|
|
296
|
+
:blah)
|
|
297
|
+
@item_rep.path = '/woof/meow/'
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
# Set content
|
|
301
|
+
raw_content = %[background: url(/);]
|
|
302
|
+
expected_content = %[background: url(../../);]
|
|
303
|
+
|
|
304
|
+
# Test
|
|
305
|
+
actual_content = filter.run(raw_content, :type => :css)
|
|
306
|
+
assert_equal(expected_content, actual_content)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
def test_filter_css_network_path
|
|
310
|
+
# Create filter with mock item
|
|
311
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
312
|
+
|
|
313
|
+
# Mock item
|
|
314
|
+
filter.instance_eval do
|
|
315
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
316
|
+
Nanoc::Item.new(
|
|
317
|
+
'content',
|
|
318
|
+
{},
|
|
319
|
+
'/foo/bar/baz/'),
|
|
320
|
+
:blah)
|
|
321
|
+
@item_rep.path = '/woof/meow/'
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# Set content
|
|
325
|
+
raw_content = %[background: url(//example.com);]
|
|
326
|
+
expected_content = %[background: url(//example.com);]
|
|
327
|
+
|
|
328
|
+
# Test
|
|
329
|
+
actual_content = filter.run(raw_content, :type => :css)
|
|
330
|
+
assert_equal(expected_content, actual_content)
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def test_filter_xml
|
|
334
|
+
if_have 'nokogiri' do
|
|
335
|
+
# Create filter with mock item
|
|
336
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
337
|
+
|
|
338
|
+
# Mock item
|
|
339
|
+
filter.instance_eval do
|
|
340
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
341
|
+
Nanoc::Item.new(
|
|
342
|
+
'content',
|
|
343
|
+
{},
|
|
344
|
+
'/foo/bar/baz/'),
|
|
345
|
+
:blah)
|
|
346
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
# Set content
|
|
350
|
+
raw_content = <<-XML
|
|
351
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
352
|
+
<foo>
|
|
353
|
+
<bar boo="/foo">baz</bar>
|
|
354
|
+
</foo>
|
|
355
|
+
XML
|
|
356
|
+
|
|
357
|
+
expected_content = <<-XML
|
|
358
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
359
|
+
<foo>
|
|
360
|
+
<bar boo="../..">baz</bar>
|
|
361
|
+
</foo>
|
|
362
|
+
XML
|
|
363
|
+
|
|
364
|
+
# Test
|
|
365
|
+
actual_content = filter.run(raw_content, :type => :xml, :select => ['*/@boo'])
|
|
366
|
+
assert_equal(expected_content, actual_content)
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def test_filter_fragment_xml
|
|
371
|
+
if_have 'nokogiri' do
|
|
372
|
+
# Create filter with mock item
|
|
373
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
374
|
+
|
|
375
|
+
# Mock item
|
|
376
|
+
filter.instance_eval do
|
|
377
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
378
|
+
Nanoc::Item.new(
|
|
379
|
+
'content',
|
|
380
|
+
{},
|
|
381
|
+
'/foo/bar/baz/'),
|
|
382
|
+
:blah)
|
|
383
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
# Set content
|
|
387
|
+
raw_content = <<-XML
|
|
388
|
+
<foo>
|
|
389
|
+
<bar><far href="/foo">baz</far></bar>
|
|
390
|
+
</foo>
|
|
391
|
+
XML
|
|
392
|
+
|
|
393
|
+
expected_content = <<-XML
|
|
394
|
+
<foo>
|
|
395
|
+
<bar><far href="../..">baz</far></bar>
|
|
396
|
+
</foo>
|
|
397
|
+
XML
|
|
398
|
+
|
|
399
|
+
# Test
|
|
400
|
+
actual_content = filter.run(raw_content, :type => :xml, :select => ['far/@href'])
|
|
401
|
+
assert_equal(expected_content, actual_content)
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def test_filter_xml_with_namespaces
|
|
406
|
+
if_have 'nokogiri' do
|
|
407
|
+
# Create filter with mock item
|
|
408
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
409
|
+
|
|
410
|
+
# Mock item
|
|
411
|
+
filter.instance_eval do
|
|
412
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
413
|
+
Nanoc::Item.new(
|
|
414
|
+
'content',
|
|
415
|
+
{},
|
|
416
|
+
'/foo/bar/baz/'),
|
|
417
|
+
:blah)
|
|
418
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
# Set content
|
|
422
|
+
raw_content = <<-XML
|
|
423
|
+
<foo xmlns="http://example.org">
|
|
424
|
+
<bar><a href="/foo">baz</a></bar>
|
|
425
|
+
</foo>
|
|
426
|
+
XML
|
|
427
|
+
|
|
428
|
+
expected_content = <<-XML
|
|
429
|
+
<foo xmlns="http://example.org">
|
|
430
|
+
<bar><a href="../..">baz</a></bar>
|
|
431
|
+
</foo>
|
|
432
|
+
XML
|
|
433
|
+
|
|
434
|
+
# Test
|
|
435
|
+
actual_content = filter.run(raw_content, {
|
|
436
|
+
:type => :xml,
|
|
437
|
+
:namespaces => {:ex => 'http://example.org'},
|
|
438
|
+
:select => ['ex:a/@href']
|
|
439
|
+
})
|
|
440
|
+
assert_equal(expected_content, actual_content)
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
def test_filter_xhtml
|
|
445
|
+
if_have 'nokogiri' do
|
|
446
|
+
# Create filter with mock item
|
|
447
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
448
|
+
|
|
449
|
+
# Mock item
|
|
450
|
+
filter.instance_eval do
|
|
451
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
452
|
+
Nanoc::Item.new(
|
|
453
|
+
'content',
|
|
454
|
+
{},
|
|
455
|
+
'/foo/bar/baz/'),
|
|
456
|
+
:blah)
|
|
457
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
# Set content
|
|
461
|
+
raw_content = <<-XML
|
|
462
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
463
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
464
|
+
<head>
|
|
465
|
+
<link rel="stylesheet" href="/css"/>
|
|
466
|
+
<script src="/js"></script>
|
|
467
|
+
</head>
|
|
468
|
+
<body>
|
|
469
|
+
<a href="/foo">bar</a>
|
|
470
|
+
<img src="/img"/>
|
|
471
|
+
</body>
|
|
472
|
+
</html>
|
|
473
|
+
XML
|
|
474
|
+
|
|
475
|
+
expected_content = <<-XML
|
|
476
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
477
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
478
|
+
<head>
|
|
479
|
+
<link rel="stylesheet" href="../../../css" />
|
|
480
|
+
<script src="../../../js"></script>
|
|
481
|
+
</head>
|
|
482
|
+
<body>
|
|
483
|
+
<a href="../..">bar</a>
|
|
484
|
+
<img src="../../../img" />
|
|
485
|
+
</body>
|
|
486
|
+
</html>
|
|
487
|
+
XML
|
|
488
|
+
|
|
489
|
+
# Test
|
|
490
|
+
actual_content = filter.run(raw_content, :type => :xhtml)
|
|
491
|
+
assert_equal(expected_content, actual_content)
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def test_filter_fragment_xhtml
|
|
496
|
+
if_have 'nokogiri' do
|
|
497
|
+
# Create filter with mock item
|
|
498
|
+
filter = Nanoc::Filters::RelativizePaths.new
|
|
499
|
+
|
|
500
|
+
# Mock item
|
|
501
|
+
filter.instance_eval do
|
|
502
|
+
@item_rep = Nanoc::ItemRep.new(
|
|
503
|
+
Nanoc::Item.new(
|
|
504
|
+
'content',
|
|
505
|
+
{},
|
|
506
|
+
'/foo/bar/baz/'),
|
|
507
|
+
:blah)
|
|
508
|
+
@item_rep.path = '/foo/bar/baz/'
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
# Set content
|
|
512
|
+
raw_content = <<-XML
|
|
513
|
+
<a href="/foo">bar</a>
|
|
514
|
+
<p>
|
|
515
|
+
<img src="/img"/>
|
|
516
|
+
</p>
|
|
517
|
+
XML
|
|
518
|
+
|
|
519
|
+
expected_content = <<-XML
|
|
520
|
+
<a href="../..">bar</a>
|
|
521
|
+
<p>
|
|
522
|
+
<img src="../../../img" />
|
|
523
|
+
</p>
|
|
524
|
+
XML
|
|
525
|
+
|
|
526
|
+
# Test
|
|
527
|
+
actual_content = filter.run(raw_content, :type => :xhtml)
|
|
528
|
+
assert_equal(expected_content, actual_content)
|
|
529
|
+
end
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
end
|