nanoc3 3.1.7 → 3.1.8
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/LICENSE +1 -1
- data/NEWS.md +9 -0
- data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
- data/lib/nanoc3/base/item.rb +1 -1
- data/lib/nanoc3/base/item_rep.rb +1 -0
- data/lib/nanoc3/base/layout.rb +1 -1
- data/lib/nanoc3/cli/base.rb +4 -2
- data/lib/nanoc3/cli/commands/view.rb +1 -0
- data/lib/nanoc3/data_sources/filesystem.rb +25 -6
- data/lib/nanoc3/data_sources/filesystem_unified.rb +5 -5
- data/lib/nanoc3/extra/validators/links.rb +1 -1
- data/lib/nanoc3/filters/rdiscount.rb +2 -1
- data/lib/nanoc3/filters/sass.rb +20 -8
- data/lib/nanoc3/filters/sass.rb.orig +75 -0
- data/lib/nanoc3.rb +1 -1
- data/nanoc3.gemspec +41 -0
- data/tasks/clean.rake +11 -0
- data/tasks/doc.rake +14 -0
- data/tasks/gem.rake +13 -0
- data/tasks/test.rake +38 -0
- data/test/base/core_ext/array_spec.rb +23 -0
- data/test/base/core_ext/hash_spec.rb +41 -0
- data/test/base/core_ext/string_spec.rb +27 -0
- data/test/base/test_code_snippet.rb +33 -0
- data/test/base/test_compiler.rb +410 -0
- data/test/base/test_compiler_dsl.rb +121 -0
- data/test/base/test_context.rb +33 -0
- data/test/base/test_data_source.rb +48 -0
- data/test/base/test_dependency_tracker.rb +510 -0
- data/test/base/test_directed_graph.rb +91 -0
- data/test/base/test_filter.rb +85 -0
- data/test/base/test_item.rb +141 -0
- data/test/base/test_item_rep.rb +953 -0
- data/test/base/test_layout.rb +44 -0
- data/test/base/test_notification_center.rb +36 -0
- data/test/base/test_plugin.rb +32 -0
- data/test/base/test_rule.rb +21 -0
- data/test/base/test_rule_context.rb +63 -0
- data/test/base/test_site.rb +366 -0
- data/test/cli/commands/test_compile.rb +12 -0
- data/test/cli/commands/test_create_item.rb +12 -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_help.rb +12 -0
- data/test/cli/commands/test_info.rb +12 -0
- data/test/cli/commands/test_update.rb +12 -0
- data/test/cli/test_logger.rb +12 -0
- data/test/data_sources/test_filesystem.rb +420 -0
- data/test/data_sources/test_filesystem_unified.rb +538 -0
- data/test/data_sources/test_filesystem_verbose.rb +359 -0
- data/test/extra/core_ext/test_enumerable.rb +32 -0
- data/test/extra/core_ext/test_time.rb +17 -0
- data/test/extra/deployers/test_rsync.rb +234 -0
- data/test/extra/test_auto_compiler.rb +482 -0
- data/test/extra/test_file_proxy.rb +21 -0
- data/test/extra/test_vcs.rb +24 -0
- data/test/extra/validators/test_links.rb +53 -0
- data/test/extra/validators/test_w3c.rb +49 -0
- data/test/filters/test_bluecloth.rb +20 -0
- data/test/filters/test_coderay.rb +46 -0
- data/test/filters/test_colorize_syntax.rb +56 -0
- data/test/filters/test_erb.rb +72 -0
- data/test/filters/test_erubis.rb +72 -0
- data/test/filters/test_haml.rb +98 -0
- data/test/filters/test_kramdown.rb +20 -0
- data/test/filters/test_less.rb +59 -0
- data/test/filters/test_markaby.rb +26 -0
- data/test/filters/test_maruku.rb +20 -0
- data/test/filters/test_rainpress.rb +31 -0
- data/test/filters/test_rdiscount.rb +33 -0
- data/test/filters/test_rdoc.rb +18 -0
- data/test/filters/test_redcloth.rb +20 -0
- data/test/filters/test_relativize_paths.rb +231 -0
- data/test/filters/test_rubypants.rb +20 -0
- data/test/filters/test_sass.rb +170 -0
- data/test/filters/test_sass.rb.orig +103 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +99 -0
- data/test/helpers/test_blogging.rb +808 -0
- data/test/helpers/test_breadcrumbs.rb +83 -0
- data/test/helpers/test_capturing.rb +42 -0
- data/test/helpers/test_filtering.rb +108 -0
- data/test/helpers/test_html_escape.rb +18 -0
- data/test/helpers/test_link_to.rb +251 -0
- data/test/helpers/test_rendering.rb +109 -0
- data/test/helpers/test_tagging.rb +89 -0
- data/test/helpers/test_text.rb +26 -0
- data/test/helpers/test_xml_sitemap.rb +69 -0
- data/test/tasks/test_clean.rb +71 -0
- metadata +83 -8
@@ -0,0 +1,141 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test/helper'
|
4
|
+
|
5
|
+
class Nanoc3::ItemTest < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
include Nanoc3::TestHelpers
|
8
|
+
|
9
|
+
def test_initialize_with_attributes_with_string_keys
|
10
|
+
item = Nanoc3::Item.new("foo", { 'abc' => 'xyz' }, '/foo/')
|
11
|
+
|
12
|
+
assert_equal nil, item.attributes['abc']
|
13
|
+
assert_equal 'xyz', item.attributes[:abc]
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_initialize_with_unclean_identifier
|
17
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
18
|
+
|
19
|
+
assert_equal '/foo/', item.identifier
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_frozen_identifier
|
23
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
24
|
+
|
25
|
+
error = assert_raises(RuntimeError) do
|
26
|
+
item.identifier.chop!
|
27
|
+
end
|
28
|
+
assert_equal "can't modify frozen string", error.message
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_lookup
|
32
|
+
# Create item
|
33
|
+
item = Nanoc3::Item.new(
|
34
|
+
"content",
|
35
|
+
{ :one => 'one in item' },
|
36
|
+
'/path/'
|
37
|
+
)
|
38
|
+
|
39
|
+
# Test finding one
|
40
|
+
assert_equal('one in item', item[:one])
|
41
|
+
|
42
|
+
# Test finding two
|
43
|
+
assert_equal(nil, item[:two])
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_set_attribute
|
47
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
48
|
+
assert_equal nil, item[:motto]
|
49
|
+
|
50
|
+
item[:motto] = 'More human than human'
|
51
|
+
assert_equal 'More human than human', item[:motto]
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_compiled_content_with_default_rep_and_default_snapshot
|
55
|
+
# Mock rep
|
56
|
+
rep = Object.new
|
57
|
+
def rep.name ; :default ; end
|
58
|
+
def rep.compiled_content(params)
|
59
|
+
"content at #{params[:snapshot].inspect}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Mock item
|
63
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
64
|
+
item.expects(:reps).returns([ rep ])
|
65
|
+
|
66
|
+
# Check
|
67
|
+
assert_equal 'content at nil', item.compiled_content
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_compiled_content_with_custom_rep_and_default_snapshot
|
71
|
+
# Mock reps
|
72
|
+
rep = Object.new
|
73
|
+
def rep.name ; :foo ; end
|
74
|
+
def rep.compiled_content(params)
|
75
|
+
"content at #{params[:snapshot].inspect}"
|
76
|
+
end
|
77
|
+
|
78
|
+
# Mock item
|
79
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
80
|
+
item.expects(:reps).returns([ rep ])
|
81
|
+
|
82
|
+
# Check
|
83
|
+
assert_equal 'content at nil', item.compiled_content(:rep => :foo)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_compiled_content_with_default_rep_and_custom_snapshot
|
87
|
+
# Mock reps
|
88
|
+
rep = Object.new
|
89
|
+
def rep.name ; :default ; end
|
90
|
+
def rep.compiled_content(params)
|
91
|
+
"content at #{params[:snapshot].inspect}"
|
92
|
+
end
|
93
|
+
|
94
|
+
# Mock item
|
95
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
96
|
+
item.expects(:reps).returns([ rep ])
|
97
|
+
|
98
|
+
# Check
|
99
|
+
assert_equal 'content at :blah', item.compiled_content(:snapshot => :blah)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_compiled_content_with_custom_nonexistant_rep
|
103
|
+
# Mock item
|
104
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
105
|
+
item.expects(:reps).returns([])
|
106
|
+
|
107
|
+
# Check
|
108
|
+
assert_raises(Nanoc3::Errors::Generic) do
|
109
|
+
item.compiled_content(:rep => :lkasdhflahgwfe)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_path_with_default_rep
|
114
|
+
# Mock reps
|
115
|
+
rep = mock
|
116
|
+
rep.expects(:name).returns(:default)
|
117
|
+
rep.expects(:path).returns('the correct path')
|
118
|
+
|
119
|
+
# Mock item
|
120
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
121
|
+
item.expects(:reps).returns([ rep ])
|
122
|
+
|
123
|
+
# Check
|
124
|
+
assert_equal 'the correct path', item.path
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_path_with_custom_rep
|
128
|
+
# Mock reps
|
129
|
+
rep = mock
|
130
|
+
rep.expects(:name).returns(:moo)
|
131
|
+
rep.expects(:path).returns('the correct path')
|
132
|
+
|
133
|
+
# Mock item
|
134
|
+
item = Nanoc3::Item.new("foo", {}, '/foo')
|
135
|
+
item.expects(:reps).returns([ rep ])
|
136
|
+
|
137
|
+
# Check
|
138
|
+
assert_equal 'the correct path', item.path(:rep => :moo)
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|