nanoc3 3.2.4 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- metadata +14 -313
- data/.gemtest +0 -0
- data/ChangeLog +0 -3
- data/Gemfile +0 -29
- data/LICENSE +0 -19
- data/NEWS.md +0 -449
- data/README.md +0 -108
- data/Rakefile +0 -14
- data/bin/nanoc3 +0 -12
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/nanoc3.rb +0 -28
- data/lib/nanoc3/base.rb +0 -49
- data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
- data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
- data/lib/nanoc3/base/compilation/compiler.rb +0 -455
- data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
- data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
- data/lib/nanoc3/base/compilation/filter.rb +0 -165
- data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
- data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
- data/lib/nanoc3/base/compilation/rule.rb +0 -73
- data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
- data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
- data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
- data/lib/nanoc3/base/context.rb +0 -47
- data/lib/nanoc3/base/core_ext.rb +0 -6
- data/lib/nanoc3/base/core_ext/array.rb +0 -62
- data/lib/nanoc3/base/core_ext/hash.rb +0 -63
- data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
- data/lib/nanoc3/base/core_ext/string.rb +0 -46
- data/lib/nanoc3/base/directed_graph.rb +0 -275
- data/lib/nanoc3/base/errors.rb +0 -174
- data/lib/nanoc3/base/memoization.rb +0 -67
- data/lib/nanoc3/base/notification_center.rb +0 -84
- data/lib/nanoc3/base/ordered_hash.rb +0 -200
- data/lib/nanoc3/base/plugin_registry.rb +0 -165
- data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
- data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
- data/lib/nanoc3/base/source_data/configuration.rb +0 -24
- data/lib/nanoc3/base/source_data/data_source.rb +0 -234
- data/lib/nanoc3/base/source_data/item.rb +0 -301
- data/lib/nanoc3/base/source_data/layout.rb +0 -130
- data/lib/nanoc3/base/source_data/site.rb +0 -361
- data/lib/nanoc3/base/store.rb +0 -135
- data/lib/nanoc3/cli.rb +0 -133
- data/lib/nanoc3/cli/command.rb +0 -139
- data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
- data/lib/nanoc3/cli/commands/compile.rb +0 -280
- data/lib/nanoc3/cli/commands/create_item.rb +0 -62
- data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
- data/lib/nanoc3/cli/commands/create_site.rb +0 -410
- data/lib/nanoc3/cli/commands/debug.rb +0 -119
- data/lib/nanoc3/cli/commands/info.rb +0 -98
- data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
- data/lib/nanoc3/cli/commands/update.rb +0 -72
- data/lib/nanoc3/cli/commands/view.rb +0 -84
- data/lib/nanoc3/cli/commands/watch.rb +0 -125
- data/lib/nanoc3/cli/error_handler.rb +0 -193
- data/lib/nanoc3/cli/logger.rb +0 -91
- data/lib/nanoc3/data_sources.rb +0 -29
- data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
- data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
- data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
- data/lib/nanoc3/data_sources/filesystem.rb +0 -299
- data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
- data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
- data/lib/nanoc3/extra.rb +0 -22
- data/lib/nanoc3/extra/auto_compiler.rb +0 -103
- data/lib/nanoc3/extra/chick.rb +0 -125
- data/lib/nanoc3/extra/core_ext.rb +0 -4
- data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
- data/lib/nanoc3/extra/core_ext/time.rb +0 -19
- data/lib/nanoc3/extra/deployers.rb +0 -11
- data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
- data/lib/nanoc3/extra/file_proxy.rb +0 -40
- data/lib/nanoc3/extra/validators.rb +0 -12
- data/lib/nanoc3/extra/validators/links.rb +0 -264
- data/lib/nanoc3/extra/validators/w3c.rb +0 -95
- data/lib/nanoc3/extra/vcs.rb +0 -66
- data/lib/nanoc3/extra/vcses.rb +0 -17
- data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
- data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
- data/lib/nanoc3/extra/vcses/git.rb +0 -25
- data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
- data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
- data/lib/nanoc3/filters.rb +0 -53
- data/lib/nanoc3/filters/asciidoc.rb +0 -38
- data/lib/nanoc3/filters/bluecloth.rb +0 -19
- data/lib/nanoc3/filters/coderay.rb +0 -21
- data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
- data/lib/nanoc3/filters/erb.rb +0 -35
- data/lib/nanoc3/filters/erubis.rb +0 -27
- data/lib/nanoc3/filters/haml.rb +0 -27
- data/lib/nanoc3/filters/kramdown.rb +0 -20
- data/lib/nanoc3/filters/less.rb +0 -53
- data/lib/nanoc3/filters/markaby.rb +0 -20
- data/lib/nanoc3/filters/maruku.rb +0 -20
- data/lib/nanoc3/filters/mustache.rb +0 -24
- data/lib/nanoc3/filters/rainpress.rb +0 -19
- data/lib/nanoc3/filters/rdiscount.rb +0 -22
- data/lib/nanoc3/filters/rdoc.rb +0 -33
- data/lib/nanoc3/filters/redcarpet.rb +0 -27
- data/lib/nanoc3/filters/redcloth.rb +0 -47
- data/lib/nanoc3/filters/relativize_paths.rb +0 -45
- data/lib/nanoc3/filters/rubypants.rb +0 -20
- data/lib/nanoc3/filters/sass.rb +0 -66
- data/lib/nanoc3/filters/slim.rb +0 -25
- data/lib/nanoc3/filters/typogruby.rb +0 -23
- data/lib/nanoc3/filters/uglify_js.rb +0 -42
- data/lib/nanoc3/helpers.rb +0 -16
- data/lib/nanoc3/helpers/blogging.rb +0 -319
- data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
- data/lib/nanoc3/helpers/capturing.rb +0 -138
- data/lib/nanoc3/helpers/filtering.rb +0 -50
- data/lib/nanoc3/helpers/html_escape.rb +0 -55
- data/lib/nanoc3/helpers/link_to.rb +0 -151
- data/lib/nanoc3/helpers/rendering.rb +0 -140
- data/lib/nanoc3/helpers/tagging.rb +0 -71
- data/lib/nanoc3/helpers/text.rb +0 -44
- data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
- data/lib/nanoc3/tasks.rb +0 -10
- data/lib/nanoc3/tasks/clean.rake +0 -16
- data/lib/nanoc3/tasks/clean.rb +0 -29
- data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
- data/lib/nanoc3/tasks/validate.rake +0 -92
- data/nanoc3.gemspec +0 -49
- data/tasks/doc.rake +0 -16
- data/tasks/test.rake +0 -44
- data/test/base/core_ext/array_spec.rb +0 -73
- data/test/base/core_ext/hash_spec.rb +0 -98
- data/test/base/core_ext/pathname_spec.rb +0 -27
- data/test/base/core_ext/string_spec.rb +0 -37
- data/test/base/test_checksum_store.rb +0 -35
- data/test/base/test_code_snippet.rb +0 -31
- data/test/base/test_compiler.rb +0 -316
- data/test/base/test_compiler_dsl.rb +0 -161
- data/test/base/test_context.rb +0 -31
- data/test/base/test_data_source.rb +0 -46
- data/test/base/test_dependency_tracker.rb +0 -262
- data/test/base/test_directed_graph.rb +0 -283
- data/test/base/test_filter.rb +0 -83
- data/test/base/test_item.rb +0 -179
- data/test/base/test_item_rep.rb +0 -553
- data/test/base/test_layout.rb +0 -59
- data/test/base/test_memoization.rb +0 -90
- data/test/base/test_notification_center.rb +0 -34
- data/test/base/test_outdatedness_checker.rb +0 -394
- data/test/base/test_plugin.rb +0 -30
- data/test/base/test_rule.rb +0 -19
- data/test/base/test_rule_context.rb +0 -65
- data/test/base/test_site.rb +0 -190
- data/test/cli/commands/test_compile.rb +0 -33
- data/test/cli/commands/test_create_item.rb +0 -14
- 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 -11
- data/test/cli/commands/test_update.rb +0 -10
- data/test/cli/test_cli.rb +0 -102
- data/test/cli/test_error_handler.rb +0 -29
- data/test/cli/test_logger.rb +0 -10
- data/test/data_sources/test_filesystem.rb +0 -433
- data/test/data_sources/test_filesystem_unified.rb +0 -536
- data/test/data_sources/test_filesystem_verbose.rb +0 -357
- data/test/extra/core_ext/test_enumerable.rb +0 -30
- data/test/extra/core_ext/test_time.rb +0 -15
- data/test/extra/deployers/test_rsync.rb +0 -232
- data/test/extra/test_auto_compiler.rb +0 -417
- data/test/extra/test_file_proxy.rb +0 -19
- data/test/extra/test_vcs.rb +0 -22
- data/test/extra/validators/test_links.rb +0 -51
- data/test/extra/validators/test_w3c.rb +0 -47
- data/test/filters/test_asciidoc.rb +0 -22
- data/test/filters/test_bluecloth.rb +0 -18
- data/test/filters/test_coderay.rb +0 -44
- data/test/filters/test_colorize_syntax.rb +0 -283
- data/test/filters/test_erb.rb +0 -99
- data/test/filters/test_erubis.rb +0 -70
- data/test/filters/test_haml.rb +0 -96
- data/test/filters/test_kramdown.rb +0 -18
- data/test/filters/test_less.rb +0 -113
- data/test/filters/test_markaby.rb +0 -24
- data/test/filters/test_maruku.rb +0 -18
- data/test/filters/test_mustache.rb +0 -25
- data/test/filters/test_rainpress.rb +0 -29
- data/test/filters/test_rdiscount.rb +0 -31
- data/test/filters/test_rdoc.rb +0 -18
- data/test/filters/test_redcarpet.rb +0 -63
- data/test/filters/test_redcloth.rb +0 -33
- data/test/filters/test_relativize_paths.rb +0 -332
- data/test/filters/test_rubypants.rb +0 -18
- data/test/filters/test_sass.rb +0 -229
- data/test/filters/test_slim.rb +0 -35
- data/test/filters/test_typogruby.rb +0 -21
- data/test/filters/test_uglify_js.rb +0 -30
- data/test/gem_loader.rb +0 -11
- data/test/helper.rb +0 -179
- data/test/helpers/test_blogging.rb +0 -754
- data/test/helpers/test_breadcrumbs.rb +0 -81
- data/test/helpers/test_capturing.rb +0 -41
- data/test/helpers/test_filtering.rb +0 -106
- data/test/helpers/test_html_escape.rb +0 -32
- data/test/helpers/test_link_to.rb +0 -249
- data/test/helpers/test_rendering.rb +0 -89
- data/test/helpers/test_tagging.rb +0 -87
- data/test/helpers/test_text.rb +0 -24
- data/test/helpers/test_xml_sitemap.rb +0 -103
- data/test/tasks/test_clean.rb +0 -67
@@ -1,754 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class Nanoc3::Helpers::BloggingTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
include Nanoc3::TestHelpers
|
6
|
-
|
7
|
-
include Nanoc3::Helpers::Blogging
|
8
|
-
include Nanoc3::Helpers::Text
|
9
|
-
|
10
|
-
def mock_article
|
11
|
-
item = mock
|
12
|
-
item.stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
13
|
-
item.stubs(:[]).with(:kind).returns('article')
|
14
|
-
item.stubs(:[]).with(:created_at).returns(Time.now - 1000)
|
15
|
-
item.stubs(:[]).with(:title).returns('An Item')
|
16
|
-
item.stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
17
|
-
item.stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
18
|
-
item.stubs(:[]).with(:excerpt).returns(nil)
|
19
|
-
item.stubs(:path).returns("/item/")
|
20
|
-
item.stubs(:[]).with(:author_name).returns(nil)
|
21
|
-
item.stubs(:[]).with(:author_uri).returns(nil)
|
22
|
-
item.stubs(:compiled_content).returns('item content')
|
23
|
-
item
|
24
|
-
end
|
25
|
-
|
26
|
-
def mock_item
|
27
|
-
item = mock
|
28
|
-
item.stubs(:[]).with(:kind).returns('item')
|
29
|
-
item
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_articles
|
33
|
-
# Create items
|
34
|
-
@items = [
|
35
|
-
Nanoc3::Item.new(
|
36
|
-
'blah',
|
37
|
-
{ :kind => 'item' },
|
38
|
-
'/0/'
|
39
|
-
),
|
40
|
-
Nanoc3::Item.new(
|
41
|
-
'blah blah',
|
42
|
-
{ :kind => 'article' },
|
43
|
-
'/1/'
|
44
|
-
),
|
45
|
-
Nanoc3::Item.new(
|
46
|
-
'blah blah blah',
|
47
|
-
{ :kind => 'article' },
|
48
|
-
'/2/'
|
49
|
-
)
|
50
|
-
]
|
51
|
-
|
52
|
-
# Check
|
53
|
-
assert_equal(2, articles.size)
|
54
|
-
assert articles.include?(@items[1])
|
55
|
-
assert articles.include?(@items[2])
|
56
|
-
ensure
|
57
|
-
# Cleanup
|
58
|
-
@items = nil
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_sorted_articles
|
62
|
-
# Create items
|
63
|
-
@items = [
|
64
|
-
Nanoc3::Item.new(
|
65
|
-
'blah',
|
66
|
-
{ :kind => 'item' },
|
67
|
-
'/0/'
|
68
|
-
),
|
69
|
-
Nanoc3::Item.new(
|
70
|
-
'blah',
|
71
|
-
{ :kind => 'article', :created_at => (Date.today - 1).to_s },
|
72
|
-
'/1/'
|
73
|
-
),
|
74
|
-
Nanoc3::Item.new(
|
75
|
-
'blah',
|
76
|
-
{ :kind => 'article', :created_at => (Time.now - 500).to_s },
|
77
|
-
'/2/'
|
78
|
-
)
|
79
|
-
]
|
80
|
-
|
81
|
-
# Check
|
82
|
-
assert_equal(2, sorted_articles.size)
|
83
|
-
assert_equal(@items[2], sorted_articles[0])
|
84
|
-
assert_equal(@items[1], sorted_articles[1])
|
85
|
-
ensure
|
86
|
-
# Cleanup
|
87
|
-
@items = nil
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_atom_feed
|
91
|
-
if_have 'builder' do
|
92
|
-
# Create items
|
93
|
-
@items = [ mock, mock_article, mock_article ]
|
94
|
-
|
95
|
-
# Create item 0
|
96
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
97
|
-
|
98
|
-
# Create item 1
|
99
|
-
@items[1].stubs(:[]).with(:updated_at).returns(Date.today - 1)
|
100
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
101
|
-
@items[1].stubs(:[]).with(:created_at).returns((Date.today - 2).to_s)
|
102
|
-
@items[1].stubs(:[]).with(:title).returns('Item One')
|
103
|
-
@items[1].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
104
|
-
@items[1].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
105
|
-
@items[1].stubs(:[]).with(:excerpt).returns(nil)
|
106
|
-
@items[1].stubs(:path).returns("/item1/")
|
107
|
-
@items[1].expects(:compiled_content).with(:snapshot => :pre).returns('item 1 content')
|
108
|
-
|
109
|
-
# Create item 2
|
110
|
-
@items[2].expects(:compiled_content).with(:snapshot => :pre).returns('item 2 content')
|
111
|
-
|
112
|
-
# Mock site
|
113
|
-
@site = mock
|
114
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
115
|
-
|
116
|
-
# Create feed item
|
117
|
-
@item = mock
|
118
|
-
@item.stubs(:[]).with(:title).returns('My Cool Blog')
|
119
|
-
@item.stubs(:[]).with(:author_name).returns('Denis Defreyne')
|
120
|
-
@item.stubs(:[]).with(:author_uri).returns('http://stoneship.org/')
|
121
|
-
@item.stubs(:[]).with(:feed_url).returns(nil)
|
122
|
-
@item.stubs(:path).returns("/journal/feed/")
|
123
|
-
|
124
|
-
# Check
|
125
|
-
atom_feed
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_atom_feed_with_times
|
130
|
-
if_have 'builder' do
|
131
|
-
# Create items
|
132
|
-
@items = [ mock_item, mock_article, mock_article ]
|
133
|
-
|
134
|
-
# Create item 1
|
135
|
-
@items[1].stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
136
|
-
@items[1].stubs(:[]).with(:created_at).returns(Time.now - 1000)
|
137
|
-
@items[1].expects(:compiled_content).returns('item 1 content')
|
138
|
-
|
139
|
-
# Create item 2
|
140
|
-
@items[2].stubs(:[]).with(:updated_at).returns(Time.now - 250)
|
141
|
-
@items[2].stubs(:[]).with(:created_at).returns(Time.now - 1200)
|
142
|
-
@items[2].expects(:compiled_content).returns('item 2 content')
|
143
|
-
|
144
|
-
# Mock site
|
145
|
-
@site = mock
|
146
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
147
|
-
|
148
|
-
# Create feed item
|
149
|
-
@item = mock
|
150
|
-
@item.stubs(:[]).with(:title).returns('My Cool Blog')
|
151
|
-
@item.stubs(:[]).with(:author_name).returns('Denis Defreyne')
|
152
|
-
@item.stubs(:[]).with(:author_uri).returns('http://stoneship.org/')
|
153
|
-
@item.stubs(:[]).with(:feed_url).returns(nil)
|
154
|
-
@item.stubs(:path).returns("/journal/feed/")
|
155
|
-
|
156
|
-
# Check
|
157
|
-
atom_feed
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_atom_feed_without_articles
|
162
|
-
if_have 'builder' do
|
163
|
-
# Mock items
|
164
|
-
@items = [ mock_item, mock_item ]
|
165
|
-
|
166
|
-
# Mock site
|
167
|
-
@site = mock
|
168
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
169
|
-
|
170
|
-
# Create feed item
|
171
|
-
@item = mock
|
172
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
173
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
174
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
175
|
-
|
176
|
-
# Check
|
177
|
-
error = assert_raises(RuntimeError) do
|
178
|
-
atom_feed
|
179
|
-
end
|
180
|
-
assert_equal(
|
181
|
-
'Cannot build Atom feed: no articles',
|
182
|
-
error.message
|
183
|
-
)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_atom_feed_without_base_url
|
188
|
-
if_have 'builder' do
|
189
|
-
# Create items
|
190
|
-
@items = [ mock_item, mock_article ]
|
191
|
-
|
192
|
-
# Mock site
|
193
|
-
@site = mock
|
194
|
-
@site.stubs(:config).returns({:base_url => nil})
|
195
|
-
|
196
|
-
# Create feed item
|
197
|
-
@item = mock
|
198
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
199
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
200
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
201
|
-
|
202
|
-
# Check
|
203
|
-
error = assert_raises(RuntimeError) do
|
204
|
-
atom_feed
|
205
|
-
end
|
206
|
-
assert_equal(
|
207
|
-
'Cannot build Atom feed: site configuration has no base_url',
|
208
|
-
error.message
|
209
|
-
)
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_atom_feed_without_title
|
214
|
-
if_have 'builder' do
|
215
|
-
# Create items
|
216
|
-
@items = [ mock_item, mock_article ]
|
217
|
-
|
218
|
-
# Mock site
|
219
|
-
@site = mock
|
220
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
221
|
-
|
222
|
-
# Create feed item
|
223
|
-
@item = mock
|
224
|
-
@item.stubs(:[]).with(:title).returns(nil)
|
225
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
226
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
227
|
-
|
228
|
-
# Check
|
229
|
-
error = assert_raises(RuntimeError) do
|
230
|
-
atom_feed
|
231
|
-
end
|
232
|
-
assert_equal(
|
233
|
-
'Cannot build Atom feed: no title in params, item or site config',
|
234
|
-
error.message
|
235
|
-
)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_atom_feed_without_author_name
|
240
|
-
if_have 'builder' do
|
241
|
-
# Create items
|
242
|
-
@items = [ mock_item, mock_article ]
|
243
|
-
|
244
|
-
# Mock site
|
245
|
-
@site = mock
|
246
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
247
|
-
|
248
|
-
# Create feed item
|
249
|
-
@item = mock
|
250
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
251
|
-
@item.stubs(:[]).with(:author_name).returns(nil)
|
252
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
253
|
-
|
254
|
-
# Check
|
255
|
-
error = assert_raises(RuntimeError) do
|
256
|
-
atom_feed
|
257
|
-
end
|
258
|
-
assert_equal(
|
259
|
-
'Cannot build Atom feed: no author_name in params, item or site config',
|
260
|
-
error.message
|
261
|
-
)
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_atom_feed_with_author_name_and_uri_from_content_item
|
266
|
-
if_have 'builder' do
|
267
|
-
# Create items
|
268
|
-
@items = [ mock_article ]
|
269
|
-
|
270
|
-
# Create item 1
|
271
|
-
@items[0].stubs(:[]).with(:author_name).returns("Don Alias")
|
272
|
-
@items[0].stubs(:[]).with(:author_uri).returns("http://don.example.com/")
|
273
|
-
@items[0].expects(:compiled_content).returns('item 1 content')
|
274
|
-
|
275
|
-
# Mock site
|
276
|
-
@site = mock
|
277
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com/' })
|
278
|
-
|
279
|
-
# Create feed item
|
280
|
-
@item = mock
|
281
|
-
@item.stubs(:[]).with(:kind).returns(nil)
|
282
|
-
@item.stubs(:[]).with(:title).returns('My Cool Blog')
|
283
|
-
@item.stubs(:[]).with(:author_name).returns('Denis Defreyne')
|
284
|
-
@item.stubs(:[]).with(:author_uri).returns('http://stoneship.org/')
|
285
|
-
@item.stubs(:[]).with(:feed_url).returns(nil)
|
286
|
-
@item.stubs(:path).returns("/journal/feed/")
|
287
|
-
|
288
|
-
# Check
|
289
|
-
# TODO: Use xpath matchers for more specific test
|
290
|
-
result = atom_feed
|
291
|
-
# Still should keep feed level author
|
292
|
-
assert_match(
|
293
|
-
/#{Regexp.escape('<name>Denis Defreyne</name>')}/, #'
|
294
|
-
result
|
295
|
-
)
|
296
|
-
assert_match(
|
297
|
-
/#{Regexp.escape('<uri>http://stoneship.org/</uri>')}/, #'
|
298
|
-
result
|
299
|
-
)
|
300
|
-
|
301
|
-
# Overrides on specific items
|
302
|
-
assert_match(
|
303
|
-
/#{Regexp.escape('<name>Don Alias</name>')}/, #'
|
304
|
-
result
|
305
|
-
)
|
306
|
-
assert_match(
|
307
|
-
/#{Regexp.escape('<uri>http://don.example.com/</uri>')}/, #'
|
308
|
-
result
|
309
|
-
)
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
def test_atom_feed_without_author_uri
|
314
|
-
if_have 'builder' do
|
315
|
-
# Create items
|
316
|
-
@items = [ mock_item, mock_article ]
|
317
|
-
|
318
|
-
# Mock site
|
319
|
-
@site = mock
|
320
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
321
|
-
|
322
|
-
# Create feed item
|
323
|
-
@item = mock
|
324
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
325
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
326
|
-
@item.stubs(:[]).with(:author_uri).returns(nil)
|
327
|
-
|
328
|
-
# Check
|
329
|
-
error = assert_raises(RuntimeError) do
|
330
|
-
atom_feed
|
331
|
-
end
|
332
|
-
assert_equal(
|
333
|
-
'Cannot build Atom feed: no author_uri in params, item or site config',
|
334
|
-
error.message
|
335
|
-
)
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
def test_atom_feed_without_articles_created_at
|
340
|
-
if_have 'builder' do
|
341
|
-
# Create items
|
342
|
-
@items = [ mock_item, mock_article, mock_article ]
|
343
|
-
@items[1].stubs(:[]).with(:created_at).returns(Time.now.to_s)
|
344
|
-
@items[2].stubs(:[]).with(:created_at).returns(nil)
|
345
|
-
|
346
|
-
# Mock site
|
347
|
-
@site = mock
|
348
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
349
|
-
|
350
|
-
# Create feed item
|
351
|
-
@item = mock
|
352
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
353
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
354
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
355
|
-
|
356
|
-
# Check
|
357
|
-
error = assert_raises(RuntimeError) do
|
358
|
-
atom_feed
|
359
|
-
end
|
360
|
-
assert_equal(
|
361
|
-
'Cannot build Atom feed: one or more articles lack created_at',
|
362
|
-
error.message
|
363
|
-
)
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
def test_atom_feed_with_title_author_name_and_uri_as_params
|
368
|
-
if_have 'builder' do
|
369
|
-
# Create items
|
370
|
-
@items = [ mock_item, mock_article ]
|
371
|
-
@items[1].expects(:compiled_content).with(:snapshot => :pre).returns('asdf')
|
372
|
-
|
373
|
-
# Mock site
|
374
|
-
@site = mock
|
375
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
376
|
-
|
377
|
-
# Create feed item
|
378
|
-
@item = mock
|
379
|
-
@item.stubs(:[]).with(:title).returns(nil)
|
380
|
-
@item.stubs(:[]).with(:author_name).returns(nil)
|
381
|
-
@item.stubs(:[]).with(:author_uri).returns(nil)
|
382
|
-
@item.stubs(:[]).with(:[]).with(:feed_url).returns('http://example.com/feed')
|
383
|
-
|
384
|
-
# Check
|
385
|
-
atom_feed(
|
386
|
-
:author_name => 'Bob',
|
387
|
-
:author_uri => 'http://example.com/~bob/',
|
388
|
-
:title => 'My Blog Or Something'
|
389
|
-
)
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
def test_atom_feed_with_title_author_name_and_uri_from_config
|
394
|
-
if_have 'builder' do
|
395
|
-
# Create items
|
396
|
-
@items = [ mock_item, mock_article ]
|
397
|
-
@items[1].expects(:compiled_content).with(:snapshot => :pre).returns('asdf')
|
398
|
-
|
399
|
-
# Mock site
|
400
|
-
@config = {
|
401
|
-
:author_name => 'Bob',
|
402
|
-
:author_uri => 'http://example.com/~bob/',
|
403
|
-
:title => 'My Blog Or Something',
|
404
|
-
:base_url => 'http://example.com'
|
405
|
-
}
|
406
|
-
@site = mock
|
407
|
-
@site.stubs(:config).returns(@config)
|
408
|
-
|
409
|
-
# Create feed item
|
410
|
-
@item = mock
|
411
|
-
@item.stubs(:[]).with(:title).returns(nil)
|
412
|
-
@item.stubs(:[]).with(:author_name).returns(nil)
|
413
|
-
@item.stubs(:[]).with(:author_uri).returns(nil)
|
414
|
-
@item.stubs(:[]).with(:[]).with(:feed_url).returns('http://example.com/feed')
|
415
|
-
|
416
|
-
# Check
|
417
|
-
atom_feed
|
418
|
-
end
|
419
|
-
end
|
420
|
-
|
421
|
-
def test_atom_feed_with_articles_param
|
422
|
-
if_have 'builder' do
|
423
|
-
# Mock items
|
424
|
-
@items = [ mock_article, mock_article ]
|
425
|
-
|
426
|
-
@items[0].expects(:compiled_content).never
|
427
|
-
@items[1].stubs(:[]).with(:title).returns('Item One')
|
428
|
-
@items[1].expects(:compiled_content).with(:snapshot => :pre).returns('asdf')
|
429
|
-
|
430
|
-
# Mock site
|
431
|
-
@site = mock
|
432
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
433
|
-
|
434
|
-
# Create feed item
|
435
|
-
@item = mock
|
436
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
437
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
438
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
439
|
-
@item.stubs(:[]).with(:[]).with(:feed_url).returns('http://example.com/feed')
|
440
|
-
|
441
|
-
# Check
|
442
|
-
atom_feed :articles => [ @items[1] ]
|
443
|
-
end
|
444
|
-
end
|
445
|
-
|
446
|
-
def test_atom_feed_with_limit_param
|
447
|
-
if_have 'builder' do
|
448
|
-
# Mock articles
|
449
|
-
@items = [ mock_article, mock_article ]
|
450
|
-
@items.each_with_index do |article, i|
|
451
|
-
article.stubs(:[]).with(:title).returns("Article #{i}")
|
452
|
-
article.stubs(:[]).with(:created_at).returns(Time.now - i)
|
453
|
-
end
|
454
|
-
|
455
|
-
# Mock site
|
456
|
-
@site = mock
|
457
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
458
|
-
|
459
|
-
# Create feed item
|
460
|
-
@item = mock
|
461
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
462
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
463
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
464
|
-
@item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
|
465
|
-
|
466
|
-
# Check
|
467
|
-
result = atom_feed :limit => 1, :articles => @items
|
468
|
-
assert_match(
|
469
|
-
Regexp.new('Article 0', Regexp::MULTILINE),
|
470
|
-
result
|
471
|
-
)
|
472
|
-
refute_match(
|
473
|
-
Regexp.new('Article 1', Regexp::MULTILINE),
|
474
|
-
result
|
475
|
-
)
|
476
|
-
end
|
477
|
-
end
|
478
|
-
|
479
|
-
def test_atom_feed_sorting
|
480
|
-
if_have 'builder' do
|
481
|
-
# Mock articles
|
482
|
-
@items = [ mock_article, mock_article ]
|
483
|
-
@items.each_with_index do |article, i|
|
484
|
-
article.stubs(:[]).with(:title).returns("Article #{i}")
|
485
|
-
end
|
486
|
-
@items[0].stubs(:[]).with(:created_at).returns('23-02-2009')
|
487
|
-
@items[1].stubs(:[]).with(:created_at).returns('22-03-2009')
|
488
|
-
|
489
|
-
# Mock site
|
490
|
-
@site = mock
|
491
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
492
|
-
|
493
|
-
# Create feed item
|
494
|
-
@item = mock
|
495
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
496
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
497
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
498
|
-
@item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
|
499
|
-
|
500
|
-
# Check
|
501
|
-
result = atom_feed
|
502
|
-
assert_match(
|
503
|
-
Regexp.new('Article 1.*Article 0', Regexp::MULTILINE),
|
504
|
-
result
|
505
|
-
)
|
506
|
-
end
|
507
|
-
end
|
508
|
-
|
509
|
-
def test_atom_feed_with_content_proc_param
|
510
|
-
if_have 'builder' do
|
511
|
-
# Mock article
|
512
|
-
@items = [ mock_article ]
|
513
|
-
|
514
|
-
# Mock site
|
515
|
-
@site = mock
|
516
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
517
|
-
|
518
|
-
# Create feed item
|
519
|
-
@item = mock
|
520
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
521
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
522
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
523
|
-
@item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
|
524
|
-
|
525
|
-
# Check
|
526
|
-
result = atom_feed :content_proc => lambda { |a| 'foobar!' }
|
527
|
-
assert_match 'foobar!</content>', result
|
528
|
-
end
|
529
|
-
end
|
530
|
-
|
531
|
-
def test_atom_feed_with_excerpt_proc_param
|
532
|
-
if_have 'builder' do
|
533
|
-
# Mock article
|
534
|
-
@items = [ mock_article ]
|
535
|
-
|
536
|
-
# Mock site
|
537
|
-
@site = mock
|
538
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
539
|
-
|
540
|
-
# Create feed item
|
541
|
-
@item = mock
|
542
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
543
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
544
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
545
|
-
@item.stubs(:[]).with(:[]).with(:feed_url).returns('http://example.com/feed')
|
546
|
-
|
547
|
-
# Check
|
548
|
-
result = atom_feed :excerpt_proc => lambda { |a| 'foobar!' }
|
549
|
-
assert_match 'foobar!</summary>', result
|
550
|
-
end
|
551
|
-
end
|
552
|
-
|
553
|
-
def test_atom_feed_with_item_without_path
|
554
|
-
if_have 'builder' do
|
555
|
-
# Create items
|
556
|
-
@items = [ mock_article ]
|
557
|
-
@items[0].stubs(:path).returns(nil)
|
558
|
-
|
559
|
-
# Mock site
|
560
|
-
@site = mock
|
561
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
562
|
-
|
563
|
-
# Create feed item
|
564
|
-
@item = mock
|
565
|
-
@item.stubs(:identifier).returns('/feed/')
|
566
|
-
@item.stubs(:[]).with(:title).returns('My Cool Blog')
|
567
|
-
@item.stubs(:[]).with(:author_name).returns('Denis Defreyne')
|
568
|
-
@item.stubs(:[]).with(:author_uri).returns('http://stoneship.org/')
|
569
|
-
@item.stubs(:[]).with(:feed_url).returns(nil)
|
570
|
-
@item.stubs(:path).returns("/journal/feed/")
|
571
|
-
|
572
|
-
# Check
|
573
|
-
atom_feed
|
574
|
-
end
|
575
|
-
end
|
576
|
-
|
577
|
-
def test_url_for_without_custom_path_in_feed
|
578
|
-
# Create site
|
579
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
580
|
-
|
581
|
-
# Create article
|
582
|
-
item = Nanoc3::Item.new('content', {}, '/foo/')
|
583
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
584
|
-
item.reps[0].path = '/foo/bar/'
|
585
|
-
|
586
|
-
# Check
|
587
|
-
assert_equal('http://example.com/foo/bar/', url_for(item))
|
588
|
-
ensure
|
589
|
-
# Cleanup
|
590
|
-
@item = nil
|
591
|
-
end
|
592
|
-
|
593
|
-
def test_url_for_with_custom_path_in_feed
|
594
|
-
# Create site
|
595
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
596
|
-
|
597
|
-
# Create article
|
598
|
-
item = Nanoc3::Item.new(
|
599
|
-
'content', { :custom_path_in_feed => '/meow/woof/' }, '/foo/')
|
600
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
601
|
-
|
602
|
-
# Check
|
603
|
-
assert_equal('http://example.com/meow/woof/', url_for(item))
|
604
|
-
ensure
|
605
|
-
# Cleanup
|
606
|
-
@item = nil
|
607
|
-
end
|
608
|
-
|
609
|
-
def test_url_for_with_custom_url_in_feed
|
610
|
-
# Create site
|
611
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
612
|
-
|
613
|
-
# Create article
|
614
|
-
item = Nanoc3::Item.new(
|
615
|
-
'content', { :custom_url_in_feed => 'http://example.org/x' }, '/foo/')
|
616
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
617
|
-
|
618
|
-
# Check
|
619
|
-
assert_equal('http://example.org/x', url_for(item))
|
620
|
-
ensure
|
621
|
-
# Cleanup
|
622
|
-
@item = nil
|
623
|
-
end
|
624
|
-
|
625
|
-
def test_url_for_without_base_url
|
626
|
-
# Create site
|
627
|
-
@site = Nanoc3::Site.new({})
|
628
|
-
|
629
|
-
# Check
|
630
|
-
assert_raises(RuntimeError) do
|
631
|
-
url_for(nil)
|
632
|
-
end
|
633
|
-
end
|
634
|
-
|
635
|
-
def test_url_for_without_path
|
636
|
-
# Create site
|
637
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
638
|
-
|
639
|
-
# Create article
|
640
|
-
item = Nanoc3::Item.new('content', {}, '/foo/')
|
641
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
642
|
-
item.reps[0].path = nil
|
643
|
-
|
644
|
-
# Check
|
645
|
-
assert_equal(nil, url_for(item))
|
646
|
-
end
|
647
|
-
|
648
|
-
def test_feed_url_without_custom_feed_url
|
649
|
-
# Create site
|
650
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
651
|
-
|
652
|
-
# Create article
|
653
|
-
@item = Nanoc3::Item.new('content', {}, '/foo/')
|
654
|
-
@item.reps << Nanoc3::ItemRep.new(@item, :default)
|
655
|
-
@item.reps[0].path = '/foo/bar/'
|
656
|
-
|
657
|
-
# Check
|
658
|
-
assert_equal('http://example.com/foo/bar/', feed_url)
|
659
|
-
ensure
|
660
|
-
# Cleanup
|
661
|
-
@item = nil
|
662
|
-
end
|
663
|
-
|
664
|
-
def test_feed_url_with_custom_feed_url
|
665
|
-
# Create site
|
666
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
667
|
-
|
668
|
-
# Create feed item
|
669
|
-
@item = Nanoc3::Item.new('content', { :feed_url => 'http://example.com/feed/' }, '/foo/')
|
670
|
-
@item.reps << Nanoc3::ItemRep.new(@item, :default)
|
671
|
-
@item.reps[0].path = '/foo/bar/'
|
672
|
-
|
673
|
-
# Check
|
674
|
-
assert_equal('http://example.com/feed/', feed_url)
|
675
|
-
ensure
|
676
|
-
# Cleanup
|
677
|
-
@item = nil
|
678
|
-
end
|
679
|
-
|
680
|
-
def test_feed_url_without_base_url
|
681
|
-
# Create site
|
682
|
-
@site = Nanoc3::Site.new({})
|
683
|
-
|
684
|
-
# Check
|
685
|
-
assert_raises(RuntimeError) do
|
686
|
-
feed_url
|
687
|
-
end
|
688
|
-
end
|
689
|
-
|
690
|
-
def test_atom_tag_for_with_path
|
691
|
-
# Create site
|
692
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
693
|
-
|
694
|
-
# Create article
|
695
|
-
item = Nanoc3::Item.new('content', { :created_at => '2008-05-19' }, '/foo/')
|
696
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
697
|
-
item.reps[0].path = '/foo/bar/'
|
698
|
-
|
699
|
-
# Check
|
700
|
-
assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
|
701
|
-
end
|
702
|
-
|
703
|
-
def test_atom_tag_for_without_path
|
704
|
-
# Create site
|
705
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
706
|
-
|
707
|
-
# Create article
|
708
|
-
item = Nanoc3::Item.new('content', { :created_at => '2008-05-19' }, '/baz/qux/')
|
709
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
710
|
-
|
711
|
-
# Check
|
712
|
-
assert_equal('tag:example.com,2008-05-19:/baz/qux/', atom_tag_for(item))
|
713
|
-
end
|
714
|
-
|
715
|
-
def test_atom_tag_for_with_base_url_in_dir
|
716
|
-
# Create site
|
717
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com/somedir' })
|
718
|
-
|
719
|
-
# Create article
|
720
|
-
item = Nanoc3::Item.new('content', { :created_at => '2008-05-19' }, '/foo/')
|
721
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
722
|
-
item.reps[0].path = '/foo/bar/'
|
723
|
-
|
724
|
-
# Check
|
725
|
-
assert_equal('tag:example.com,2008-05-19:/somedir/foo/bar/', atom_tag_for(item))
|
726
|
-
end
|
727
|
-
|
728
|
-
def test_atom_tag_for_with_time
|
729
|
-
# Create site
|
730
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
731
|
-
|
732
|
-
# Create article
|
733
|
-
item = Nanoc3::Item.new('content', { :created_at => Time.parse('2008-05-19') }, '/foo/')
|
734
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
735
|
-
item.reps[0].path = '/foo/bar/'
|
736
|
-
|
737
|
-
# Check
|
738
|
-
assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
|
739
|
-
end
|
740
|
-
|
741
|
-
def test_atom_tag_for_with_date
|
742
|
-
# Create site
|
743
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
744
|
-
|
745
|
-
# Create article
|
746
|
-
item = Nanoc3::Item.new('content', { :created_at => Date.parse('2008-05-19') }, '/foo/')
|
747
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
748
|
-
item.reps[0].path = '/foo/bar/'
|
749
|
-
|
750
|
-
# Check
|
751
|
-
assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
|
752
|
-
end
|
753
|
-
|
754
|
-
end
|