nanoc3 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,81 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Helpers::BreadcrumbsTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- include Nanoc3::Helpers::Breadcrumbs
8
-
9
- def test_breadcrumbs_trail_at_root
10
- # Mock item
11
- @item = mock
12
- @item.stubs(:identifier).returns('/')
13
- @items = [ @item ]
14
-
15
- # Build trail
16
- trail = breadcrumbs_trail
17
-
18
- # Check
19
- assert_equal(
20
- [ @item ],
21
- trail
22
- )
23
- end
24
-
25
- def test_breadcrumbs_trail_with_1_parent
26
- # Mock item
27
- parent = mock
28
- parent.stubs(:identifier).returns('/')
29
- @item = mock
30
- @item.stubs(:identifier).returns('/foo/')
31
- @items = [ parent, @item ]
32
-
33
- # Build trail
34
- trail = breadcrumbs_trail
35
-
36
- # Check
37
- assert_equal(
38
- [ parent, @item ],
39
- trail
40
- )
41
- end
42
-
43
- def test_breadcrumbs_trail_with_many_parents
44
- # Mock item
45
- grandparent = mock
46
- grandparent.stubs(:identifier).returns('/')
47
- parent = mock
48
- parent.stubs(:identifier).returns('/foo/')
49
- @item = mock
50
- @item.stubs(:identifier).returns('/foo/bar/')
51
- @items = [ grandparent, parent, @item ]
52
-
53
- # Build trail
54
- trail = breadcrumbs_trail
55
-
56
- # Check
57
- assert_equal(
58
- [ grandparent, parent, @item ],
59
- trail
60
- )
61
- end
62
-
63
- def test_breadcrumbs_trail_with_nils
64
- # Mock item
65
- grandparent = mock
66
- grandparent.stubs(:identifier).returns('/')
67
- @item = mock
68
- @item.stubs(:identifier).returns('/foo/bar/')
69
- @items = [ grandparent, @item ]
70
-
71
- # Build trail
72
- trail = breadcrumbs_trail
73
-
74
- # Check
75
- assert_equal(
76
- [ grandparent, nil, @item ],
77
- trail
78
- )
79
- end
80
-
81
- end
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Helpers::CapturingTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- include Nanoc3::Helpers::Capturing
8
-
9
- def test_content_for
10
- require 'erb'
11
-
12
- # Build content to be evaluated
13
- content = "head <% content_for :sidebar do %>\n" +
14
- " <%= 1+2 %>\n" +
15
- "<% end %> foot"
16
-
17
- # Evaluate content
18
- @item = Nanoc3::Item.new('moo', {}, '/blah/')
19
- result = ::ERB.new(content).result(binding)
20
-
21
- # Check
22
- assert_equal '3', content_for(@item, :sidebar).strip
23
- assert_equal '3', @item[:content_for_sidebar].strip
24
- assert_match(/^head\s+foot$/, result)
25
- end
26
-
27
- def test_capture
28
- require 'erb'
29
-
30
- # Capture
31
- _erbout = 'foo'
32
- captured_content = capture do
33
- _erbout << 'bar'
34
- end
35
-
36
- # Check
37
- assert_equal 'foo', _erbout
38
- assert_equal 'bar', captured_content
39
- end
40
-
41
- end
@@ -1,106 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Helpers::FilteringTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- include Nanoc3::Helpers::Filtering
8
-
9
- def test_filter_simple
10
- if_have 'rubypants' do
11
- # Build content to be evaluated
12
- content = "<p>Foo...</p>\n" +
13
- "<% filter :rubypants do %>\n" +
14
- " <p>Bar...</p>\n" +
15
- "<% end %>\n"
16
-
17
- # Mock item and rep
18
- @item_rep = mock
19
- @item_rep.expects(:assigns).returns({})
20
-
21
- # Evaluate content
22
- result = ::ERB.new(content).result(binding)
23
-
24
- # Check
25
- assert_match('<p>Foo...</p>', result)
26
- assert_match('<p>Bar&#8230;</p>', result)
27
- end
28
- end
29
-
30
- def test_filter_with_assigns
31
- if_have 'rubypants' do
32
- # Build content to be evaluated
33
- content = "<p>Foo...</p>\n" +
34
- "<% filter :erb do %>\n" +
35
- " <p><%%= @item[:title] %></p>\n" +
36
- "<% end %>\n"
37
-
38
- # Mock item and rep
39
- @item = mock
40
- @item.expects(:[]).with(:title).returns('Bar...')
41
- @item.expects(:identifier).returns('/blah/')
42
- @item_rep = mock
43
- @item_rep.expects(:name).returns('default')
44
- @item_rep.expects(:assigns).returns({
45
- :item => @item,
46
- :item_rep => @item_rep
47
- })
48
-
49
- # Evaluate content
50
- result = ::ERB.new(content).result(binding)
51
-
52
- # Check
53
- assert_match('<p>Foo...</p>', result)
54
- assert_match('<p>Bar...</p>', result)
55
- end
56
- end
57
-
58
- def test_filter_with_unknown_filter_name
59
- # Build content to be evaluated
60
- content = "<p>Foo...</p>\n" +
61
- "<% filter :askjdflkawgjlkwaheflnvz do %>\n" +
62
- " <p>Blah blah blah.</p>\n" +
63
- "<% end %>\n"
64
-
65
- # Evaluate content
66
- error = assert_raises(Nanoc3::Errors::UnknownFilter) do
67
- ::ERB.new(content).result(binding)
68
- end
69
- end
70
-
71
- def test_filter_with_arguments
72
- if_have 'coderay' do
73
- # Build content to be evaluated
74
- content = "<% filter :coderay, :language => 'ruby' do %>\n" +
75
- " def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end\n" +
76
- "<% end %>\n"
77
-
78
- # Mock item and rep
79
- @item_rep = mock
80
- @item_rep.expects(:assigns).returns({})
81
-
82
- # Evaluate content
83
- result = ::ERB.new(content).result(binding)
84
- assert_match(%r{<span class="keyword">def</span> <span class="function">some_function</span>}, result)
85
- end
86
- end
87
-
88
- def test_with_haml
89
- if_have 'haml' do
90
- # Build content to be evaluated
91
- content = "%p Foo.\n" +
92
- "- filter(:erb) do\n" +
93
- " <%= 'abc' + 'xyz' %>\n" +
94
- "%p Bar.\n"
95
-
96
- # Mock item and rep
97
- @item_rep = mock
98
- @item_rep.expects(:assigns).returns({})
99
-
100
- # Evaluate content
101
- result = ::Haml::Engine.new(content).render(binding)
102
- assert_match(%r{^<p>Foo.</p>\s*abcxyz\s*<p>Bar.</p>$}, result)
103
- end
104
- end
105
-
106
- end
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Helpers::HTMLEscapeTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- include Nanoc3::Helpers::HTMLEscape
8
-
9
- def test_html_escape_with_string
10
- assert_equal('&lt;', html_escape('<'))
11
- assert_equal('&gt;', html_escape('>'))
12
- assert_equal('&amp;', html_escape('&'))
13
- assert_equal('&quot;', html_escape('"'))
14
- end
15
-
16
- def test_html_escape_with_block
17
- _erbout = 'moo'
18
-
19
- html_escape do
20
- _erbout << '<h1>Looks like a header</h1>'
21
- end
22
-
23
- assert_equal 'moo&lt;h1&gt;Looks like a header&lt;/h1&gt;', _erbout
24
- end
25
-
26
- def test_html_escape_without_string_or_block
27
- assert_raises RuntimeError do
28
- h
29
- end
30
- end
31
-
32
- end
@@ -1,249 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Helpers::LinkToTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- include Nanoc3::Helpers::LinkTo
8
-
9
- def test_link_to_with_path
10
- # Check
11
- assert_equal(
12
- '<a href="/foo/">Foo</a>',
13
- link_to('Foo', '/foo/')
14
- )
15
- end
16
-
17
- def test_link_to_with_rep
18
- # Create rep
19
- rep = mock
20
- rep.stubs(:path).returns('/bar/')
21
-
22
- # Check
23
- assert_equal(
24
- '<a href="/bar/">Bar</a>',
25
- link_to('Bar', rep)
26
- )
27
- end
28
-
29
- def test_link_to_with_item
30
- # Create rep
31
- item = mock
32
- item.stubs(:path).returns('/bar/')
33
-
34
- # Check
35
- assert_equal(
36
- '<a href="/bar/">Bar</a>',
37
- link_to('Bar', item)
38
- )
39
- end
40
-
41
- def test_link_to_with_attributes
42
- # Check
43
- assert_equal(
44
- '<a title="Dis mai foo!" href="/foo/">Foo</a>',
45
- link_to('Foo', '/foo/', :title => 'Dis mai foo!')
46
- )
47
- end
48
-
49
- def test_link_to_escape
50
- # Check
51
- assert_equal(
52
- '<a title="Foo &amp; Bar" href="/foo&amp;bar/">Foo &amp; Bar</a>',
53
- link_to('Foo &amp; Bar', '/foo&bar/', :title => 'Foo & Bar')
54
- )
55
- end
56
-
57
- def test_link_to_to_nil_item_or_item_rep
58
- obj = Object.new
59
- def obj.path ; nil ; end
60
-
61
- assert_raises RuntimeError do
62
- link_to("Some Text", obj)
63
- end
64
- end
65
-
66
- def test_link_to_unless_current_current
67
- # Create item
68
- @item_rep = mock
69
- @item_rep.stubs(:path).returns('/foo/')
70
-
71
- # Check
72
- assert_equal(
73
- '<span class="active" title="You\'re here.">Bar</span>',
74
- link_to_unless_current('Bar', @item_rep)
75
- )
76
- ensure
77
- @item = nil
78
- end
79
-
80
- def test_link_to_unless_current_not_current
81
- # Create item
82
- @item_rep = mock
83
- @item_rep.stubs(:path).returns('/foo/')
84
-
85
- # Check
86
- assert_equal(
87
- '<a href="/abc/xyz/">Bar</a>',
88
- link_to_unless_current('Bar', '/abc/xyz/')
89
- )
90
- end
91
-
92
- def test_relative_path_to_with_self
93
- # Mock item
94
- @item_rep = mock
95
- @item_rep.stubs(:path).returns('/foo/bar/baz/')
96
-
97
- # Test
98
- assert_equal(
99
- './',
100
- relative_path_to('/foo/bar/baz/')
101
- )
102
- end
103
-
104
- def test_relative_path_to_with_root
105
- # Mock item
106
- @item_rep = mock
107
- @item_rep.stubs(:path).returns('/foo/bar/baz/')
108
-
109
- # Test
110
- assert_equal(
111
- '../../../',
112
- relative_path_to('/')
113
- )
114
- end
115
-
116
- def test_relative_path_to_file
117
- # Mock item
118
- @item_rep = mock
119
- @item_rep.stubs(:path).returns('/foo/bar/baz/')
120
-
121
- # Test
122
- assert_equal(
123
- '../../quux',
124
- relative_path_to('/foo/quux')
125
- )
126
- end
127
-
128
- def test_relative_path_to_dir
129
- # Mock item
130
- @item_rep = mock
131
- @item_rep.stubs(:path).returns('/foo/bar/baz/')
132
-
133
- # Test
134
- assert_equal(
135
- '../../quux/',
136
- relative_path_to('/foo/quux/')
137
- )
138
- end
139
-
140
- def test_relative_path_to_rep
141
- # Mock self
142
- @item_rep = mock
143
- @item_rep.stubs(:path).returns('/foo/bar/baz/')
144
-
145
- # Mock other
146
- other_item_rep = mock
147
- other_item_rep.stubs(:path).returns('/foo/quux/')
148
-
149
- # Test
150
- assert_equal(
151
- '../../quux/',
152
- relative_path_to(other_item_rep)
153
- )
154
- end
155
-
156
-
157
- def test_relative_path_to_item
158
- # Mock self
159
- @item_rep = mock
160
- @item_rep.stubs(:path).returns('/foo/bar/baz/')
161
-
162
- # Mock other
163
- other_item = mock
164
- other_item.stubs(:path).returns('/foo/quux/')
165
-
166
- # Test
167
- assert_equal(
168
- '../../quux/',
169
- relative_path_to(other_item)
170
- )
171
- end
172
-
173
- def test_relative_path_to_to_nil
174
- # Mock self
175
- @item_rep = mock
176
- @item_rep.stubs(:path).returns(nil)
177
-
178
- # Mock other
179
- other_item_rep = mock
180
- other_item_rep.stubs(:path).returns('/foo/quux/')
181
-
182
- # Test
183
- assert_raises RuntimeError do
184
- relative_path_to(other_item_rep)
185
- end
186
- end
187
-
188
- def test_relative_path_to_from_nil
189
- # Mock self
190
- @item_rep = mock
191
- @item_rep.stubs(:path).returns('/foo/quux/')
192
-
193
- # Mock other
194
- other_item_rep = mock
195
- other_item_rep.stubs(:path).returns(nil)
196
-
197
- # Test
198
- assert_raises RuntimeError do
199
- relative_path_to(other_item_rep)
200
- end
201
- end
202
-
203
- def test_examples_link_to
204
- # Parse
205
- YARD.parse('../lib/nanoc3/helpers/link_to.rb')
206
-
207
- # Mock
208
- @items = [ mock, mock, mock ]
209
- @items[0].stubs(:identifier).returns('/about/')
210
- @items[0].stubs(:path).returns('/about.html')
211
- @items[1].stubs(:identifier).returns('/software/')
212
- @items[1].stubs(:path).returns('/software.html')
213
- @items[2].stubs(:identifier).returns('/software/nanoc/')
214
- @items[2].stubs(:path).returns('/software/nanoc.html')
215
- about_rep_vcard = mock
216
- about_rep_vcard.stubs(:path).returns('/about.vcf')
217
- @items[0].stubs(:rep).with(:vcard).returns(about_rep_vcard)
218
-
219
- # Run
220
- assert_examples_correct 'Nanoc3::Helpers::LinkTo#link_to'
221
- end
222
-
223
- def test_examples_link_to_unless_current
224
- # Parse
225
- YARD.parse('../lib/nanoc3/helpers/link_to.rb')
226
-
227
- # Mock
228
- @item_rep = mock
229
- @item_rep.stubs(:path).returns('/about/')
230
- @item = mock
231
- @item.stubs(:path).returns(@item_rep.path)
232
-
233
- # Run
234
- assert_examples_correct 'Nanoc3::Helpers::LinkTo#link_to_unless_current'
235
- end
236
-
237
- def test_examples_relative_path_to
238
- # Parse
239
- YARD.parse('../lib/nanoc3/helpers/link_to.rb')
240
-
241
- # Mock
242
- @item_rep = mock
243
- @item_rep.stubs(:path).returns('/foo/bar/')
244
-
245
- # Run
246
- assert_examples_correct 'Nanoc3::Helpers::LinkTo#relative_path_to'
247
- end
248
-
249
- end