nanoc3 3.1.9 → 3.2.0a1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/NEWS.md +0 -50
- data/README.md +3 -15
- data/bin/nanoc3 +2 -0
- data/lib/nanoc3/base/checksummer.rb +40 -0
- data/lib/nanoc3/base/code_snippet.rb +30 -12
- data/lib/nanoc3/base/compiled_content_cache.rb +86 -0
- data/lib/nanoc3/base/compiler.rb +134 -95
- data/lib/nanoc3/base/compiler_dsl.rb +12 -11
- data/lib/nanoc3/base/core_ext/string.rb +2 -2
- data/lib/nanoc3/base/data_source.rb +17 -16
- data/lib/nanoc3/base/dependency_tracker.rb +102 -121
- data/lib/nanoc3/base/directed_graph.rb +65 -3
- data/lib/nanoc3/base/errors.rb +20 -16
- data/lib/nanoc3/base/item.rb +58 -50
- data/lib/nanoc3/base/item_rep.rb +177 -150
- data/lib/nanoc3/base/layout.rb +51 -18
- data/lib/nanoc3/base/notification_center.rb +8 -8
- data/lib/nanoc3/base/plugin_registry.rb +9 -9
- data/lib/nanoc3/base/rule.rb +18 -9
- data/lib/nanoc3/base/rule_context.rb +5 -5
- data/lib/nanoc3/base/site.rb +135 -47
- data/lib/nanoc3/base.rb +21 -19
- data/lib/nanoc3/cli/base.rb +51 -74
- data/lib/nanoc3/cli/commands/autocompile.rb +3 -0
- data/lib/nanoc3/cli/commands/compile.rb +35 -74
- data/lib/nanoc3/cli/commands/create_site.rb +17 -5
- data/lib/nanoc3/cli/commands/debug.rb +11 -4
- data/lib/nanoc3/cli/commands/view.rb +0 -1
- data/lib/nanoc3/cli/commands/watch.rb +148 -0
- data/lib/nanoc3/cli/commands.rb +1 -0
- data/lib/nanoc3/cli/logger.rb +15 -21
- data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -1
- data/lib/nanoc3/data_sources/filesystem.rb +11 -40
- data/lib/nanoc3/data_sources/filesystem_unified.rb +22 -22
- data/lib/nanoc3/extra/auto_compiler.rb +1 -1
- data/lib/nanoc3/extra/chick.rb +8 -8
- data/lib/nanoc3/extra/deployers/rsync.rb +2 -3
- data/lib/nanoc3/extra/validators/links.rb +32 -51
- data/lib/nanoc3/extra/validators/w3c.rb +2 -2
- data/lib/nanoc3/extra/vcs.rb +1 -1
- data/lib/nanoc3/filters/colorize_syntax.rb +15 -19
- data/lib/nanoc3/filters/erb.rb +1 -5
- data/lib/nanoc3/filters/erubis.rb +1 -5
- data/lib/nanoc3/filters/haml.rb +1 -2
- data/lib/nanoc3/filters/less.rb +2 -51
- data/lib/nanoc3/filters/mustache.rb +21 -0
- data/lib/nanoc3/filters/rdiscount.rb +1 -2
- data/lib/nanoc3/filters/relativize_paths.rb +3 -2
- data/lib/nanoc3/filters/sass.rb +50 -56
- data/lib/nanoc3/filters.rb +2 -0
- data/lib/nanoc3/helpers/blogging.rb +22 -29
- data/lib/nanoc3/helpers/breadcrumbs.rb +1 -1
- data/lib/nanoc3/helpers/capturing.rb +1 -1
- data/lib/nanoc3/helpers/filtering.rb +1 -1
- data/lib/nanoc3/helpers/link_to.rb +10 -21
- data/lib/nanoc3/helpers/rendering.rb +5 -24
- data/lib/nanoc3/helpers/tagging.rb +6 -6
- data/lib/nanoc3/helpers/text.rb +2 -2
- data/lib/nanoc3.rb +1 -1
- metadata +35 -93
- data/.gemtest +0 -0
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/nanoc3.gemspec +0 -41
- data/tasks/clean.rake +0 -11
- data/tasks/doc.rake +0 -14
- data/tasks/gem.rake +0 -13
- data/tasks/test.rake +0 -38
- data/test/base/core_ext/array_spec.rb +0 -23
- data/test/base/core_ext/hash_spec.rb +0 -41
- data/test/base/core_ext/string_spec.rb +0 -27
- data/test/base/test_code_snippet.rb +0 -33
- data/test/base/test_compiler.rb +0 -410
- data/test/base/test_compiler_dsl.rb +0 -121
- data/test/base/test_context.rb +0 -33
- data/test/base/test_data_source.rb +0 -48
- data/test/base/test_dependency_tracker.rb +0 -510
- data/test/base/test_directed_graph.rb +0 -91
- data/test/base/test_filter.rb +0 -85
- data/test/base/test_item.rb +0 -141
- data/test/base/test_item_rep.rb +0 -953
- data/test/base/test_layout.rb +0 -44
- data/test/base/test_notification_center.rb +0 -36
- data/test/base/test_plugin.rb +0 -32
- data/test/base/test_rule.rb +0 -21
- data/test/base/test_rule_context.rb +0 -63
- data/test/base/test_site.rb +0 -366
- data/test/cli/commands/test_compile.rb +0 -12
- data/test/cli/commands/test_create_item.rb +0 -12
- data/test/cli/commands/test_create_layout.rb +0 -28
- data/test/cli/commands/test_create_site.rb +0 -24
- data/test/cli/commands/test_help.rb +0 -12
- data/test/cli/commands/test_info.rb +0 -12
- data/test/cli/commands/test_update.rb +0 -12
- data/test/cli/test_logger.rb +0 -12
- data/test/data_sources/test_filesystem.rb +0 -420
- data/test/data_sources/test_filesystem_unified.rb +0 -538
- data/test/data_sources/test_filesystem_verbose.rb +0 -359
- data/test/extra/core_ext/test_enumerable.rb +0 -32
- data/test/extra/core_ext/test_time.rb +0 -17
- data/test/extra/deployers/test_rsync.rb +0 -234
- data/test/extra/test_auto_compiler.rb +0 -482
- data/test/extra/test_file_proxy.rb +0 -21
- data/test/extra/test_vcs.rb +0 -24
- data/test/extra/validators/test_links.rb +0 -53
- data/test/extra/validators/test_w3c.rb +0 -49
- data/test/filters/test_bluecloth.rb +0 -20
- data/test/filters/test_coderay.rb +0 -46
- data/test/filters/test_colorize_syntax.rb +0 -84
- data/test/filters/test_erb.rb +0 -72
- data/test/filters/test_erubis.rb +0 -72
- data/test/filters/test_haml.rb +0 -98
- data/test/filters/test_kramdown.rb +0 -20
- data/test/filters/test_less.rb +0 -118
- data/test/filters/test_markaby.rb +0 -26
- data/test/filters/test_maruku.rb +0 -20
- data/test/filters/test_rainpress.rb +0 -31
- data/test/filters/test_rdiscount.rb +0 -33
- data/test/filters/test_rdoc.rb +0 -18
- data/test/filters/test_redcloth.rb +0 -20
- data/test/filters/test_relativize_paths.rb +0 -231
- data/test/filters/test_rubypants.rb +0 -20
- data/test/filters/test_sass.rb +0 -235
- data/test/gem_loader.rb +0 -11
- data/test/helper.rb +0 -99
- data/test/helpers/test_blogging.rb +0 -808
- data/test/helpers/test_breadcrumbs.rb +0 -83
- data/test/helpers/test_capturing.rb +0 -42
- data/test/helpers/test_filtering.rb +0 -108
- data/test/helpers/test_html_escape.rb +0 -18
- data/test/helpers/test_link_to.rb +0 -251
- data/test/helpers/test_rendering.rb +0 -109
- data/test/helpers/test_tagging.rb +0 -89
- data/test/helpers/test_text.rb +0 -26
- data/test/helpers/test_xml_sitemap.rb +0 -69
- data/test/tasks/test_clean.rb +0 -71
@@ -1,83 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
|
-
class Nanoc3::Helpers::BreadcrumbsTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
include Nanoc3::TestHelpers
|
8
|
-
|
9
|
-
include Nanoc3::Helpers::Breadcrumbs
|
10
|
-
|
11
|
-
def test_breadcrumbs_trail_at_root
|
12
|
-
# Mock item
|
13
|
-
@item = mock
|
14
|
-
@item.stubs(:identifier).returns('/')
|
15
|
-
@items = [ @item ]
|
16
|
-
|
17
|
-
# Build trail
|
18
|
-
trail = breadcrumbs_trail
|
19
|
-
|
20
|
-
# Check
|
21
|
-
assert_equal(
|
22
|
-
[ @item ],
|
23
|
-
trail
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_breadcrumbs_trail_with_1_parent
|
28
|
-
# Mock item
|
29
|
-
parent = mock
|
30
|
-
parent.stubs(:identifier).returns('/')
|
31
|
-
@item = mock
|
32
|
-
@item.stubs(:identifier).returns('/foo/')
|
33
|
-
@items = [ parent, @item ]
|
34
|
-
|
35
|
-
# Build trail
|
36
|
-
trail = breadcrumbs_trail
|
37
|
-
|
38
|
-
# Check
|
39
|
-
assert_equal(
|
40
|
-
[ parent, @item ],
|
41
|
-
trail
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_breadcrumbs_trail_with_many_parents
|
46
|
-
# Mock item
|
47
|
-
grandparent = mock
|
48
|
-
grandparent.stubs(:identifier).returns('/')
|
49
|
-
parent = mock
|
50
|
-
parent.stubs(:identifier).returns('/foo/')
|
51
|
-
@item = mock
|
52
|
-
@item.stubs(:identifier).returns('/foo/bar/')
|
53
|
-
@items = [ grandparent, parent, @item ]
|
54
|
-
|
55
|
-
# Build trail
|
56
|
-
trail = breadcrumbs_trail
|
57
|
-
|
58
|
-
# Check
|
59
|
-
assert_equal(
|
60
|
-
[ grandparent, parent, @item ],
|
61
|
-
trail
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_breadcrumbs_trail_with_nils
|
66
|
-
# Mock item
|
67
|
-
grandparent = mock
|
68
|
-
grandparent.stubs(:identifier).returns('/')
|
69
|
-
@item = mock
|
70
|
-
@item.stubs(:identifier).returns('/foo/bar/')
|
71
|
-
@items = [ grandparent, @item ]
|
72
|
-
|
73
|
-
# Build trail
|
74
|
-
trail = breadcrumbs_trail
|
75
|
-
|
76
|
-
# Check
|
77
|
-
assert_equal(
|
78
|
-
[ grandparent, nil, @item ],
|
79
|
-
trail
|
80
|
-
)
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
|
-
class Nanoc3::Helpers::CapturingTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
include Nanoc3::TestHelpers
|
8
|
-
|
9
|
-
include Nanoc3::Helpers::Capturing
|
10
|
-
|
11
|
-
def test_content_for
|
12
|
-
require 'erb'
|
13
|
-
|
14
|
-
# Build content to be evaluated
|
15
|
-
content = "head <% content_for :sidebar do %>\n" +
|
16
|
-
" <%= 1+2 %>\n" +
|
17
|
-
"<% end %> foot"
|
18
|
-
|
19
|
-
# Evaluate content
|
20
|
-
@item = {}
|
21
|
-
result = ::ERB.new(content).result(binding)
|
22
|
-
|
23
|
-
# Check
|
24
|
-
assert(@item[:content_for_sidebar].strip == '3')
|
25
|
-
assert_match(/^head\s+foot$/, result)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_capture
|
29
|
-
require 'erb'
|
30
|
-
|
31
|
-
# Capture
|
32
|
-
_erbout = 'foo'
|
33
|
-
captured_content = capture do
|
34
|
-
_erbout << 'bar'
|
35
|
-
end
|
36
|
-
|
37
|
-
# Check
|
38
|
-
assert_equal 'foo', _erbout
|
39
|
-
assert_equal 'bar', captured_content
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
|
-
class Nanoc3::Helpers::FilteringTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
include Nanoc3::TestHelpers
|
8
|
-
|
9
|
-
include Nanoc3::Helpers::Filtering
|
10
|
-
|
11
|
-
def test_filter_simple
|
12
|
-
if_have 'rubypants' do
|
13
|
-
# Build content to be evaluated
|
14
|
-
content = "<p>Foo...</p>\n" +
|
15
|
-
"<% filter :rubypants do %>\n" +
|
16
|
-
" <p>Bar...</p>\n" +
|
17
|
-
"<% end %>\n"
|
18
|
-
|
19
|
-
# Mock item and rep
|
20
|
-
@item_rep = mock
|
21
|
-
@item_rep.expects(:assigns).returns({})
|
22
|
-
|
23
|
-
# Evaluate content
|
24
|
-
result = ::ERB.new(content).result(binding)
|
25
|
-
|
26
|
-
# Check
|
27
|
-
assert_match('<p>Foo...</p>', result)
|
28
|
-
assert_match('<p>Bar…</p>', result)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_filter_with_assigns
|
33
|
-
if_have 'rubypants' do
|
34
|
-
# Build content to be evaluated
|
35
|
-
content = "<p>Foo...</p>\n" +
|
36
|
-
"<% filter :erb do %>\n" +
|
37
|
-
" <p><%%= @item[:title] %></p>\n" +
|
38
|
-
"<% end %>\n"
|
39
|
-
|
40
|
-
# Mock item and rep
|
41
|
-
@item = mock
|
42
|
-
@item.expects(:[]).with(:title).returns('Bar...')
|
43
|
-
@item.expects(:identifier).returns('/blah/')
|
44
|
-
@item_rep = mock
|
45
|
-
@item_rep.expects(:name).returns('default')
|
46
|
-
@item_rep.expects(:assigns).returns({
|
47
|
-
:item => @item,
|
48
|
-
:item_rep => @item_rep
|
49
|
-
})
|
50
|
-
|
51
|
-
# Evaluate content
|
52
|
-
result = ::ERB.new(content).result(binding)
|
53
|
-
|
54
|
-
# Check
|
55
|
-
assert_match('<p>Foo...</p>', result)
|
56
|
-
assert_match('<p>Bar...</p>', result)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_filter_with_unknown_filter_name
|
61
|
-
# Build content to be evaluated
|
62
|
-
content = "<p>Foo...</p>\n" +
|
63
|
-
"<% filter :askjdflkawgjlkwaheflnvz do %>\n" +
|
64
|
-
" <p>Blah blah blah.</p>\n" +
|
65
|
-
"<% end %>\n"
|
66
|
-
|
67
|
-
# Evaluate content
|
68
|
-
error = assert_raises(Nanoc3::Errors::UnknownFilter) do
|
69
|
-
::ERB.new(content).result(binding)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_filter_with_arguments
|
74
|
-
if_have 'coderay' do
|
75
|
-
# Build content to be evaluated
|
76
|
-
content = "<% filter :coderay, :language => 'ruby' do %>\n" +
|
77
|
-
" def some_function ; x = blah.foo ; x.bar 'xyzzy' ; end\n" +
|
78
|
-
"<% end %>\n"
|
79
|
-
|
80
|
-
# Mock item and rep
|
81
|
-
@item_rep = mock
|
82
|
-
@item_rep.expects(:assigns).returns({})
|
83
|
-
|
84
|
-
# Evaluate content
|
85
|
-
result = ::ERB.new(content).result(binding)
|
86
|
-
assert_match(%r{<span class="r">def</span> <span class="fu">some_function</span>}, result)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_with_haml
|
91
|
-
if_have 'haml' do
|
92
|
-
# Build content to be evaluated
|
93
|
-
content = "%p Foo.\n" +
|
94
|
-
"- filter(:erb) do\n" +
|
95
|
-
" <%= 'abc' + 'xyz' %>\n" +
|
96
|
-
"%p Bar.\n"
|
97
|
-
|
98
|
-
# Mock item and rep
|
99
|
-
@item_rep = mock
|
100
|
-
@item_rep.expects(:assigns).returns({})
|
101
|
-
|
102
|
-
# Evaluate content
|
103
|
-
result = ::Haml::Engine.new(content).render(binding)
|
104
|
-
assert_match(%r{^<p>Foo.</p>\s*abcxyz\s*<p>Bar.</p>$}, result)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
|
-
class Nanoc3::Helpers::HTMLEscapeTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
include Nanoc3::TestHelpers
|
8
|
-
|
9
|
-
include Nanoc3::Helpers::HTMLEscape
|
10
|
-
|
11
|
-
def test_html_escape
|
12
|
-
assert_equal('<', html_escape('<'))
|
13
|
-
assert_equal('>', html_escape('>'))
|
14
|
-
assert_equal('&', html_escape('&'))
|
15
|
-
assert_equal('"', html_escape('"'))
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,251 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
|
-
class Nanoc3::Helpers::LinkToTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
include Nanoc3::TestHelpers
|
8
|
-
|
9
|
-
include Nanoc3::Helpers::LinkTo
|
10
|
-
|
11
|
-
def test_link_to_with_path
|
12
|
-
# Check
|
13
|
-
assert_equal(
|
14
|
-
'<a href="/foo/">Foo</a>',
|
15
|
-
link_to('Foo', '/foo/')
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_link_to_with_rep
|
20
|
-
# Create rep
|
21
|
-
rep = mock
|
22
|
-
rep.stubs(:path).returns('/bar/')
|
23
|
-
|
24
|
-
# Check
|
25
|
-
assert_equal(
|
26
|
-
'<a href="/bar/">Bar</a>',
|
27
|
-
link_to('Bar', rep)
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_link_to_with_item
|
32
|
-
# Create rep
|
33
|
-
item = mock
|
34
|
-
item.stubs(:path).returns('/bar/')
|
35
|
-
|
36
|
-
# Check
|
37
|
-
assert_equal(
|
38
|
-
'<a href="/bar/">Bar</a>',
|
39
|
-
link_to('Bar', item)
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_link_to_with_attributes
|
44
|
-
# Check
|
45
|
-
assert_equal(
|
46
|
-
'<a title="Dis mai foo!" href="/foo/">Foo</a>',
|
47
|
-
link_to('Foo', '/foo/', :title => 'Dis mai foo!')
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_link_to_escape
|
52
|
-
# Check
|
53
|
-
assert_equal(
|
54
|
-
'<a title="Foo & Bar" href="/foo&bar/">Foo & Bar</a>',
|
55
|
-
link_to('Foo & Bar', '/foo&bar/', :title => 'Foo & Bar')
|
56
|
-
)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_link_to_to_nil_item_or_item_rep
|
60
|
-
obj = Object.new
|
61
|
-
def obj.path ; nil ; end
|
62
|
-
|
63
|
-
assert_raises RuntimeError do
|
64
|
-
link_to("Some Text", obj)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_link_to_unless_current_current
|
69
|
-
# Create item
|
70
|
-
@item_rep = mock
|
71
|
-
@item_rep.stubs(:path).returns('/foo/')
|
72
|
-
|
73
|
-
# Check
|
74
|
-
assert_equal(
|
75
|
-
'<span class="active" title="You\'re here.">Bar</span>',
|
76
|
-
link_to_unless_current('Bar', @item_rep)
|
77
|
-
)
|
78
|
-
ensure
|
79
|
-
@item = nil
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_link_to_unless_current_not_current
|
83
|
-
# Create item
|
84
|
-
@item_rep = mock
|
85
|
-
@item_rep.stubs(:path).returns('/foo/')
|
86
|
-
|
87
|
-
# Check
|
88
|
-
assert_equal(
|
89
|
-
'<a href="/abc/xyz/">Bar</a>',
|
90
|
-
link_to_unless_current('Bar', '/abc/xyz/')
|
91
|
-
)
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_relative_path_to_with_self
|
95
|
-
# Mock item
|
96
|
-
@item_rep = mock
|
97
|
-
@item_rep.stubs(:path).returns('/foo/bar/baz/')
|
98
|
-
|
99
|
-
# Test
|
100
|
-
assert_equal(
|
101
|
-
'./',
|
102
|
-
relative_path_to('/foo/bar/baz/')
|
103
|
-
)
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_relative_path_to_with_root
|
107
|
-
# Mock item
|
108
|
-
@item_rep = mock
|
109
|
-
@item_rep.stubs(:path).returns('/foo/bar/baz/')
|
110
|
-
|
111
|
-
# Test
|
112
|
-
assert_equal(
|
113
|
-
'../../../',
|
114
|
-
relative_path_to('/')
|
115
|
-
)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_relative_path_to_file
|
119
|
-
# Mock item
|
120
|
-
@item_rep = mock
|
121
|
-
@item_rep.stubs(:path).returns('/foo/bar/baz/')
|
122
|
-
|
123
|
-
# Test
|
124
|
-
assert_equal(
|
125
|
-
'../../quux',
|
126
|
-
relative_path_to('/foo/quux')
|
127
|
-
)
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_relative_path_to_dir
|
131
|
-
# Mock item
|
132
|
-
@item_rep = mock
|
133
|
-
@item_rep.stubs(:path).returns('/foo/bar/baz/')
|
134
|
-
|
135
|
-
# Test
|
136
|
-
assert_equal(
|
137
|
-
'../../quux/',
|
138
|
-
relative_path_to('/foo/quux/')
|
139
|
-
)
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_relative_path_to_rep
|
143
|
-
# Mock self
|
144
|
-
@item_rep = mock
|
145
|
-
@item_rep.stubs(:path).returns('/foo/bar/baz/')
|
146
|
-
|
147
|
-
# Mock other
|
148
|
-
other_item_rep = mock
|
149
|
-
other_item_rep.stubs(:path).returns('/foo/quux/')
|
150
|
-
|
151
|
-
# Test
|
152
|
-
assert_equal(
|
153
|
-
'../../quux/',
|
154
|
-
relative_path_to(other_item_rep)
|
155
|
-
)
|
156
|
-
end
|
157
|
-
|
158
|
-
|
159
|
-
def test_relative_path_to_item
|
160
|
-
# Mock self
|
161
|
-
@item_rep = mock
|
162
|
-
@item_rep.stubs(:path).returns('/foo/bar/baz/')
|
163
|
-
|
164
|
-
# Mock other
|
165
|
-
other_item = mock
|
166
|
-
other_item.stubs(:path).returns('/foo/quux/')
|
167
|
-
|
168
|
-
# Test
|
169
|
-
assert_equal(
|
170
|
-
'../../quux/',
|
171
|
-
relative_path_to(other_item)
|
172
|
-
)
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_relative_path_to_to_nil
|
176
|
-
# Mock self
|
177
|
-
@item_rep = mock
|
178
|
-
@item_rep.stubs(:path).returns(nil)
|
179
|
-
|
180
|
-
# Mock other
|
181
|
-
other_item_rep = mock
|
182
|
-
other_item_rep.stubs(:path).returns('/foo/quux/')
|
183
|
-
|
184
|
-
# Test
|
185
|
-
assert_raises RuntimeError do
|
186
|
-
relative_path_to(other_item_rep)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_relative_path_to_from_nil
|
191
|
-
# Mock self
|
192
|
-
@item_rep = mock
|
193
|
-
@item_rep.stubs(:path).returns('/foo/quux/')
|
194
|
-
|
195
|
-
# Mock other
|
196
|
-
other_item_rep = mock
|
197
|
-
other_item_rep.stubs(:path).returns(nil)
|
198
|
-
|
199
|
-
# Test
|
200
|
-
assert_raises RuntimeError do
|
201
|
-
relative_path_to(other_item_rep)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_examples_link_to
|
206
|
-
# Parse
|
207
|
-
YARD.parse('../lib/nanoc3/helpers/link_to.rb')
|
208
|
-
|
209
|
-
# Mock
|
210
|
-
@items = [ mock, mock, mock ]
|
211
|
-
@items[0].stubs(:identifier).returns('/about/')
|
212
|
-
@items[0].stubs(:path).returns('/about.html')
|
213
|
-
@items[1].stubs(:identifier).returns('/software/')
|
214
|
-
@items[1].stubs(:path).returns('/software.html')
|
215
|
-
@items[2].stubs(:identifier).returns('/software/nanoc/')
|
216
|
-
@items[2].stubs(:path).returns('/software/nanoc.html')
|
217
|
-
about_rep_vcard = mock
|
218
|
-
about_rep_vcard.stubs(:path).returns('/about.vcf')
|
219
|
-
@items[0].stubs(:rep).with(:vcard).returns(about_rep_vcard)
|
220
|
-
|
221
|
-
# Run
|
222
|
-
assert_examples_correct 'Nanoc3::Helpers::LinkTo#link_to'
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_examples_link_to_unless_current
|
226
|
-
# Parse
|
227
|
-
YARD.parse('../lib/nanoc3/helpers/link_to.rb')
|
228
|
-
|
229
|
-
# Mock
|
230
|
-
@item_rep = mock
|
231
|
-
@item_rep.stubs(:path).returns('/about/')
|
232
|
-
@item = mock
|
233
|
-
@item.stubs(:path).returns(@item_rep.path)
|
234
|
-
|
235
|
-
# Run
|
236
|
-
assert_examples_correct 'Nanoc3::Helpers::LinkTo#link_to_unless_current'
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_examples_relative_path_to
|
240
|
-
# Parse
|
241
|
-
YARD.parse('../lib/nanoc3/helpers/link_to.rb')
|
242
|
-
|
243
|
-
# Mock
|
244
|
-
@item_rep = mock
|
245
|
-
@item_rep.stubs(:path).returns('/foo/bar/')
|
246
|
-
|
247
|
-
# Run
|
248
|
-
assert_examples_correct 'Nanoc3::Helpers::LinkTo#relative_path_to'
|
249
|
-
end
|
250
|
-
|
251
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
|
-
class Nanoc3::Helpers::RenderingTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
include Nanoc3::TestHelpers
|
8
|
-
|
9
|
-
include Nanoc3::Helpers::Rendering
|
10
|
-
|
11
|
-
def test_render
|
12
|
-
# Mock layouts
|
13
|
-
layout = MiniTest::Mock.new
|
14
|
-
layout.expect(:identifier, '/foo/')
|
15
|
-
layout.expect(:raw_content, 'This is the <%= @layout.identifier %> layout.')
|
16
|
-
|
17
|
-
# Mock site, compiler and stack
|
18
|
-
stack = []
|
19
|
-
compiler = MiniTest::Mock.new
|
20
|
-
compiler.expect(:stack, stack)
|
21
|
-
compiler.expects(:filter_for_layout).with(layout).returns([ :erb, {} ])
|
22
|
-
@site = MiniTest::Mock.new
|
23
|
-
@site.expect(:compiler, compiler)
|
24
|
-
@site.expect(:layouts, [ layout ])
|
25
|
-
|
26
|
-
# Render
|
27
|
-
assert_equal('This is the /foo/ layout.', render('/foo/'))
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_render_with_unknown_layout
|
31
|
-
# Mock site
|
32
|
-
@site = MiniTest::Mock.new.expect(:layouts, [])
|
33
|
-
|
34
|
-
# Render
|
35
|
-
assert_raises(Nanoc3::Errors::UnknownLayout) do
|
36
|
-
render('/fawgooafwagwfe/')
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_render_without_filter
|
41
|
-
# Mock layouts
|
42
|
-
layout = MiniTest::Mock.new
|
43
|
-
layout.expect(:identifier, '/foo/')
|
44
|
-
layout.expect(:raw_content, 'This is the <%= "foo" %> layout.')
|
45
|
-
|
46
|
-
# Mock compiler
|
47
|
-
compiler = mock
|
48
|
-
compiler.stubs(:filter_for_layout).with(layout).returns(nil)
|
49
|
-
|
50
|
-
# Mock site
|
51
|
-
@site = MiniTest::Mock.new
|
52
|
-
@site.expect(:layouts, [ layout ])
|
53
|
-
@site.expect(:compiler, compiler)
|
54
|
-
|
55
|
-
# Render
|
56
|
-
assert_raises(Nanoc3::Errors::CannotDetermineFilter) do
|
57
|
-
render '/foo/'
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_render_with_unknown_filter
|
62
|
-
# Mock layouts
|
63
|
-
layout = MiniTest::Mock.new
|
64
|
-
layout.expect(:identifier, '/foo/')
|
65
|
-
layout.expect(:raw_content, 'This is the <%= "foo" %> layout.')
|
66
|
-
|
67
|
-
# Mock compiler
|
68
|
-
compiler = mock
|
69
|
-
compiler.stubs(:filter_for_layout).with(layout).returns([ :kjsdalfjwagihlawfji, {} ])
|
70
|
-
|
71
|
-
# Mock site
|
72
|
-
@site = MiniTest::Mock.new
|
73
|
-
@site.expect(:layouts, [ layout ])
|
74
|
-
@site.expect(:compiler, compiler)
|
75
|
-
|
76
|
-
# Render
|
77
|
-
assert_raises(Nanoc3::Errors::UnknownFilter) do
|
78
|
-
render '/foo/'
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_render_with_block
|
83
|
-
# Mock layouts
|
84
|
-
layout = MiniTest::Mock.new
|
85
|
-
layout.expect(:identifier, '/foo/')
|
86
|
-
layout.expect(:raw_content, '[partial-before]<%= yield %>[partial-after]')
|
87
|
-
|
88
|
-
# Mock compiler
|
89
|
-
stack = []
|
90
|
-
compiler = mock
|
91
|
-
compiler.stubs(:stack).returns(stack)
|
92
|
-
compiler.expects(:filter_for_layout).with(layout).returns([ :erb, {} ])
|
93
|
-
|
94
|
-
# Mock site
|
95
|
-
@site = MiniTest::Mock.new
|
96
|
-
@site.expect(:compiler, compiler)
|
97
|
-
@site.expect(:layouts, [ layout ])
|
98
|
-
|
99
|
-
# Mock erbout
|
100
|
-
_erbout = '[erbout-before]'
|
101
|
-
|
102
|
-
# Render
|
103
|
-
render '/foo/' do
|
104
|
-
_erbout << "This is some extra content"
|
105
|
-
end
|
106
|
-
assert_equal('[erbout-before][partial-before]This is some extra content[partial-after]', _erbout)
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
|
-
class Nanoc3::Helpers::TaggingTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
include Nanoc3::TestHelpers
|
8
|
-
|
9
|
-
include Nanoc3::Helpers::Tagging
|
10
|
-
|
11
|
-
def test_tags_for_without_tags
|
12
|
-
# Create item
|
13
|
-
item = Nanoc3::Item.new('content', {}, '/path/')
|
14
|
-
|
15
|
-
# Check
|
16
|
-
assert_equal(
|
17
|
-
'(none)',
|
18
|
-
tags_for(item)
|
19
|
-
)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_tags_for_with_custom_base_url
|
23
|
-
# Create item
|
24
|
-
item = Nanoc3::Item.new('content', { :tags => [ 'foo', 'bar' ]}, '/path/')
|
25
|
-
|
26
|
-
# Check
|
27
|
-
assert_equal(
|
28
|
-
"#{link_for_tag('foo', 'http://stoneship.org/tag/')}, " +
|
29
|
-
"#{link_for_tag('bar', 'http://stoneship.org/tag/')}",
|
30
|
-
tags_for(item, :base_url => 'http://stoneship.org/tag/')
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_tags_for_with_custom_none_text
|
35
|
-
# Create item
|
36
|
-
item = Nanoc3::Item.new('content', { :tags => [ ]}, '/path/')
|
37
|
-
|
38
|
-
# Check
|
39
|
-
assert_equal(
|
40
|
-
'no tags for you, fool',
|
41
|
-
tags_for(item, :none_text => 'no tags for you, fool')
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_tags_for_with_custom_separator
|
46
|
-
# Create item
|
47
|
-
item = Nanoc3::Item.new('content', { :tags => [ 'foo', 'bar' ]}, '/path/')
|
48
|
-
|
49
|
-
# Check
|
50
|
-
assert_equal(
|
51
|
-
"#{link_for_tag('foo', 'http://technorati.com/tag/')} ++ " +
|
52
|
-
"#{link_for_tag('bar', 'http://technorati.com/tag/')}",
|
53
|
-
tags_for(item, :separator => ' ++ ')
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_items_with_tag
|
58
|
-
# Create items
|
59
|
-
@items = [
|
60
|
-
Nanoc3::Item.new('item 1', { :tags => [ :foo ] }, '/item1/'),
|
61
|
-
Nanoc3::Item.new('item 2', { :tags => [ :bar ] }, '/item2/'),
|
62
|
-
Nanoc3::Item.new('item 3', { :tags => [ :foo, :bar ] }, '/item3/')
|
63
|
-
]
|
64
|
-
|
65
|
-
# Find items
|
66
|
-
items_with_foo_tag = items_with_tag(:foo)
|
67
|
-
|
68
|
-
# Check
|
69
|
-
assert_equal(
|
70
|
-
[ @items[0], @items[2] ],
|
71
|
-
items_with_foo_tag
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_link_for_tag
|
76
|
-
assert_equal(
|
77
|
-
%[<a href="http://stoneship.org/tags/foobar" rel="tag">foobar</a>],
|
78
|
-
link_for_tag('foobar', 'http://stoneship.org/tags/')
|
79
|
-
)
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_link_for_tag_escape
|
83
|
-
assert_equal(
|
84
|
-
%[<a href="http://stoneship.org/tags&stuff/foo&bar" rel="tag">foo&bar</a>],
|
85
|
-
link_for_tag('foo&bar', 'http://stoneship.org/tags&stuff/')
|
86
|
-
)
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|