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,808 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test/helper'
|
4
|
-
|
5
|
-
class Nanoc3::Helpers::BloggingTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
include Nanoc3::TestHelpers
|
8
|
-
|
9
|
-
include Nanoc3::Helpers::Blogging
|
10
|
-
include Nanoc3::Helpers::Text
|
11
|
-
|
12
|
-
def test_articles
|
13
|
-
# Create items
|
14
|
-
@items = [
|
15
|
-
Nanoc3::Item.new(
|
16
|
-
'blah',
|
17
|
-
{ :kind => 'item' },
|
18
|
-
'/0/'
|
19
|
-
),
|
20
|
-
Nanoc3::Item.new(
|
21
|
-
'blah blah',
|
22
|
-
{ :kind => 'article' },
|
23
|
-
'/1/'
|
24
|
-
),
|
25
|
-
Nanoc3::Item.new(
|
26
|
-
'blah blah blah',
|
27
|
-
{ :kind => 'article' },
|
28
|
-
'/2/'
|
29
|
-
)
|
30
|
-
]
|
31
|
-
|
32
|
-
# Check
|
33
|
-
assert_equal(2, articles.size)
|
34
|
-
assert articles.include?(@items[1])
|
35
|
-
assert articles.include?(@items[2])
|
36
|
-
ensure
|
37
|
-
# Cleanup
|
38
|
-
@items = nil
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_sorted_articles
|
42
|
-
# Create items
|
43
|
-
@items = [
|
44
|
-
Nanoc3::Item.new(
|
45
|
-
'blah',
|
46
|
-
{ :kind => 'item' },
|
47
|
-
'/0/'
|
48
|
-
),
|
49
|
-
Nanoc3::Item.new(
|
50
|
-
'blah',
|
51
|
-
{ :kind => 'article', :created_at => (Date.today - 1).to_s },
|
52
|
-
'/1/'
|
53
|
-
),
|
54
|
-
Nanoc3::Item.new(
|
55
|
-
'blah',
|
56
|
-
{ :kind => 'article', :created_at => (Time.now - 500).to_s },
|
57
|
-
'/2/'
|
58
|
-
)
|
59
|
-
]
|
60
|
-
|
61
|
-
# Check
|
62
|
-
assert_equal(2, sorted_articles.size)
|
63
|
-
assert_equal(@items[2], sorted_articles[0])
|
64
|
-
assert_equal(@items[1], sorted_articles[1])
|
65
|
-
ensure
|
66
|
-
# Cleanup
|
67
|
-
@items = nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_atom_feed
|
71
|
-
if_have 'builder' do
|
72
|
-
# Create items
|
73
|
-
@items = [ mock, mock, mock ]
|
74
|
-
|
75
|
-
# Create item 0
|
76
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
77
|
-
|
78
|
-
# Create item 1
|
79
|
-
@items[1].stubs(:[]).with(:updated_at).returns(Date.today - 1)
|
80
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
81
|
-
@items[1].stubs(:[]).with(:created_at).returns((Date.today - 2).to_s)
|
82
|
-
@items[1].stubs(:[]).with(:title).returns('Item One')
|
83
|
-
@items[1].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
84
|
-
@items[1].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
85
|
-
@items[1].stubs(:[]).with(:excerpt).returns(nil)
|
86
|
-
@items[1].stubs(:path).returns("/item1/")
|
87
|
-
@items[1].expects(:compiled_content).with(:snapshot => :pre).returns('item 1 content')
|
88
|
-
|
89
|
-
# Create item 2
|
90
|
-
@items[2].stubs(:[]).with(:updated_at).returns(Time.now - 250)
|
91
|
-
@items[2].stubs(:[]).with(:kind).returns('article')
|
92
|
-
@items[2].stubs(:[]).with(:created_at).returns((Time.now - 750).to_s)
|
93
|
-
@items[2].stubs(:[]).with(:title).returns('Item Two')
|
94
|
-
@items[2].stubs(:[]).with(:custom_path_in_feed).returns('/item2custom/')
|
95
|
-
@items[2].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
96
|
-
@items[2].stubs(:[]).with(:excerpt).returns('item 2 excerpt')
|
97
|
-
@items[2].stubs(:path).returns("/item2/")
|
98
|
-
@items[2].expects(:compiled_content).with(:snapshot => :pre).returns('item 2 content')
|
99
|
-
|
100
|
-
# Mock site
|
101
|
-
@site = mock
|
102
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
103
|
-
|
104
|
-
# Create feed item
|
105
|
-
@item = mock
|
106
|
-
@item.stubs(:[]).with(:title).returns('My Cool Blog')
|
107
|
-
@item.stubs(:[]).with(:author_name).returns('Denis Defreyne')
|
108
|
-
@item.stubs(:[]).with(:author_uri).returns('http://stoneship.org/')
|
109
|
-
@item.stubs(:[]).with(:feed_url).returns(nil)
|
110
|
-
@item.stubs(:path).returns("/journal/feed/")
|
111
|
-
|
112
|
-
# Check
|
113
|
-
atom_feed
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_atom_feed_with_times
|
118
|
-
if_have 'builder' do
|
119
|
-
# Create items
|
120
|
-
@items = [ mock, mock, mock ]
|
121
|
-
|
122
|
-
# Create item 0
|
123
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
124
|
-
|
125
|
-
# Create item 1
|
126
|
-
@items[1].stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
127
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
128
|
-
@items[1].stubs(:[]).with(:created_at).returns(Time.now - 1000)
|
129
|
-
@items[1].stubs(:[]).with(:title).returns('Item One')
|
130
|
-
@items[1].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
131
|
-
@items[1].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
132
|
-
@items[1].stubs(:[]).with(:excerpt).returns(nil)
|
133
|
-
@items[1].stubs(:path).returns("/item1/")
|
134
|
-
@items[1].expects(:compiled_content).returns('item 1 content')
|
135
|
-
|
136
|
-
# Create item 2
|
137
|
-
@items[2].stubs(:[]).with(:updated_at).returns(Time.now - 250)
|
138
|
-
@items[2].stubs(:[]).with(:kind).returns('article')
|
139
|
-
@items[2].stubs(:[]).with(:created_at).returns(Time.now - 1200)
|
140
|
-
@items[2].stubs(:[]).with(:title).returns('Item Two')
|
141
|
-
@items[2].stubs(:[]).with(:custom_path_in_feed).returns('/item2custom/')
|
142
|
-
@items[2].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
143
|
-
@items[2].stubs(:[]).with(:excerpt).returns('item 2 excerpt')
|
144
|
-
@items[2].stubs(:path).returns("/item2/")
|
145
|
-
@items[2].expects(:compiled_content).returns('item 2 content')
|
146
|
-
|
147
|
-
# Mock site
|
148
|
-
@site = mock
|
149
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
150
|
-
|
151
|
-
# Create feed item
|
152
|
-
@item = mock
|
153
|
-
@item.stubs(:[]).with(:title).returns('My Cool Blog')
|
154
|
-
@item.stubs(:[]).with(:author_name).returns('Denis Defreyne')
|
155
|
-
@item.stubs(:[]).with(:author_uri).returns('http://stoneship.org/')
|
156
|
-
@item.stubs(:[]).with(:feed_url).returns(nil)
|
157
|
-
@item.stubs(:path).returns("/journal/feed/")
|
158
|
-
|
159
|
-
# Check
|
160
|
-
atom_feed
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_atom_feed_without_articles
|
165
|
-
if_have 'builder' do
|
166
|
-
# Mock items
|
167
|
-
@items = [ mock, mock, mock ]
|
168
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
169
|
-
@items[1].stubs(:[]).with(:kind).returns('item')
|
170
|
-
@items[2].stubs(:[]).with(:kind).returns('item')
|
171
|
-
|
172
|
-
# Mock site
|
173
|
-
@site = mock
|
174
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
175
|
-
|
176
|
-
# Create feed item
|
177
|
-
@item = mock
|
178
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
179
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
180
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
181
|
-
|
182
|
-
# Check
|
183
|
-
error = assert_raises(RuntimeError) do
|
184
|
-
atom_feed
|
185
|
-
end
|
186
|
-
assert_equal(
|
187
|
-
'Cannot build Atom feed: no articles',
|
188
|
-
error.message
|
189
|
-
)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
def test_atom_feed_without_base_url
|
194
|
-
if_have 'builder' do
|
195
|
-
# Create items
|
196
|
-
@items = [ mock, mock ]
|
197
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
198
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
199
|
-
|
200
|
-
# Mock site
|
201
|
-
@site = mock
|
202
|
-
@site.stubs(:config).returns({:base_url => nil})
|
203
|
-
|
204
|
-
# Create feed item
|
205
|
-
@item = mock
|
206
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
207
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
208
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
209
|
-
|
210
|
-
# Check
|
211
|
-
error = assert_raises(RuntimeError) do
|
212
|
-
atom_feed
|
213
|
-
end
|
214
|
-
assert_equal(
|
215
|
-
'Cannot build Atom feed: site configuration has no base_url',
|
216
|
-
error.message
|
217
|
-
)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_atom_feed_without_title
|
222
|
-
if_have 'builder' do
|
223
|
-
# Create items
|
224
|
-
@items = [ mock, mock ]
|
225
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
226
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
227
|
-
|
228
|
-
# Mock site
|
229
|
-
@site = mock
|
230
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
231
|
-
|
232
|
-
# Create feed item
|
233
|
-
@item = mock
|
234
|
-
@item.stubs(:[]).with(:title).returns(nil)
|
235
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
236
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
237
|
-
|
238
|
-
# Check
|
239
|
-
error = assert_raises(RuntimeError) do
|
240
|
-
atom_feed
|
241
|
-
end
|
242
|
-
assert_equal(
|
243
|
-
'Cannot build Atom feed: no title in params, item or site config',
|
244
|
-
error.message
|
245
|
-
)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_atom_feed_without_author_name
|
250
|
-
if_have 'builder' do
|
251
|
-
# Create items
|
252
|
-
@items = [ mock, mock ]
|
253
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
254
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
255
|
-
|
256
|
-
# Mock site
|
257
|
-
@site = mock
|
258
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
259
|
-
|
260
|
-
# Create feed item
|
261
|
-
@item = mock
|
262
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
263
|
-
@item.stubs(:[]).with(:author_name).returns(nil)
|
264
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
265
|
-
|
266
|
-
# Check
|
267
|
-
error = assert_raises(RuntimeError) do
|
268
|
-
atom_feed
|
269
|
-
end
|
270
|
-
assert_equal(
|
271
|
-
'Cannot build Atom feed: no author_name in params, item or site config',
|
272
|
-
error.message
|
273
|
-
)
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
def test_atom_feed_without_author_uri
|
278
|
-
if_have 'builder' do
|
279
|
-
# Create items
|
280
|
-
@items = [ mock, mock ]
|
281
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
282
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
283
|
-
|
284
|
-
# Mock site
|
285
|
-
@site = mock
|
286
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
287
|
-
|
288
|
-
# Create feed item
|
289
|
-
@item = mock
|
290
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
291
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
292
|
-
@item.stubs(:[]).with(:author_uri).returns(nil)
|
293
|
-
|
294
|
-
# Check
|
295
|
-
error = assert_raises(RuntimeError) do
|
296
|
-
atom_feed
|
297
|
-
end
|
298
|
-
assert_equal(
|
299
|
-
'Cannot build Atom feed: no author_uri in params, item or site config',
|
300
|
-
error.message
|
301
|
-
)
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_atom_feed_without_articles_created_at
|
306
|
-
if_have 'builder' do
|
307
|
-
# Create items
|
308
|
-
@items = [ mock, mock, mock, mock, mock ]
|
309
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
310
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
311
|
-
@items[1].stubs(:[]).with(:created_at).returns(Time.now.to_s)
|
312
|
-
@items[2].stubs(:[]).with(:kind).returns('article')
|
313
|
-
@items[2].stubs(:[]).with(:created_at).returns(Time.now.to_s)
|
314
|
-
@items[3].stubs(:[]).with(:kind).returns('article')
|
315
|
-
@items[3].stubs(:[]).with(:created_at).returns(Time.now.to_s)
|
316
|
-
@items[4].stubs(:[]).with(:kind).returns('article')
|
317
|
-
@items[4].stubs(:[]).with(:created_at).returns(nil)
|
318
|
-
|
319
|
-
# Mock site
|
320
|
-
@site = mock
|
321
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
322
|
-
|
323
|
-
# Create feed item
|
324
|
-
@item = mock
|
325
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
326
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
327
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
328
|
-
|
329
|
-
# Check
|
330
|
-
error = assert_raises(RuntimeError) do
|
331
|
-
atom_feed
|
332
|
-
end
|
333
|
-
assert_equal(
|
334
|
-
'Cannot build Atom feed: one or more articles lack created_at',
|
335
|
-
error.message
|
336
|
-
)
|
337
|
-
end
|
338
|
-
end
|
339
|
-
|
340
|
-
def test_atom_feed_with_title_author_name_and_uri_as_params
|
341
|
-
if_have 'builder' do
|
342
|
-
# Create items
|
343
|
-
@items = [ mock, mock ]
|
344
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
345
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
346
|
-
@items[1].stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
347
|
-
@items[1].stubs(:raw_content).returns('item 1 content')
|
348
|
-
@items[1].stubs(:[]).with(:created_at).returns((Time.now - 1000).to_s)
|
349
|
-
@items[1].stubs(:[]).with(:title).returns('Item One')
|
350
|
-
@items[1].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
351
|
-
@items[1].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
352
|
-
@items[1].stubs(:[]).with(:path).returns('/item1/')
|
353
|
-
@items[1].stubs(:[]).with(:excerpt).returns(nil)
|
354
|
-
@items[1].stubs(:path).returns('/asdf/fdsa/')
|
355
|
-
@items[1].stubs(:raw_path).returns('output/asdf/fdsa/index.html')
|
356
|
-
@items[1].expects(:compiled_content).with(:snapshot => :pre).returns('asdf')
|
357
|
-
|
358
|
-
# Mock site
|
359
|
-
@site = mock
|
360
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
361
|
-
|
362
|
-
# Create feed item
|
363
|
-
@item = mock
|
364
|
-
@item.stubs(:[]).with(:title).returns(nil)
|
365
|
-
@item.stubs(:[]).with(:author_name).returns(nil)
|
366
|
-
@item.stubs(:[]).with(:author_uri).returns(nil)
|
367
|
-
@item.stubs(:[]).with(:[]).with(:feed_url).returns('http://example.com/feed')
|
368
|
-
|
369
|
-
# Check
|
370
|
-
atom_feed(
|
371
|
-
:author_name => 'Bob',
|
372
|
-
:author_uri => 'http://example.com/~bob/',
|
373
|
-
:title => 'My Blog Or Something'
|
374
|
-
)
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
def test_atom_feed_with_title_author_name_and_uri_from_config
|
379
|
-
if_have 'builder' do
|
380
|
-
# Create items
|
381
|
-
@items = [ mock, mock ]
|
382
|
-
@items[0].stubs(:[]).with(:kind).returns('item')
|
383
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
384
|
-
@items[1].stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
385
|
-
@items[1].stubs(:raw_content).returns('item 1 content')
|
386
|
-
@items[1].stubs(:[]).with(:created_at).returns((Time.now - 1000).to_s)
|
387
|
-
@items[1].stubs(:[]).with(:title).returns('Item One')
|
388
|
-
@items[1].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
389
|
-
@items[1].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
390
|
-
@items[1].stubs(:[]).with(:path).returns('/item1/')
|
391
|
-
@items[1].stubs(:[]).with(:excerpt).returns(nil)
|
392
|
-
@items[1].stubs(:path).returns('/asdf/fdsa/')
|
393
|
-
@items[1].stubs(:raw_path).returns('output/asdf/fdsa/index.html')
|
394
|
-
@items[1].expects(:compiled_content).with(:snapshot => :pre).returns('asdf')
|
395
|
-
|
396
|
-
# Mock site
|
397
|
-
@config = {
|
398
|
-
:author_name => 'Bob',
|
399
|
-
:author_uri => 'http://example.com/~bob/',
|
400
|
-
:title => 'My Blog Or Something',
|
401
|
-
:base_url => 'http://example.com'
|
402
|
-
}
|
403
|
-
@site = mock
|
404
|
-
@site.stubs(:config).returns(@config)
|
405
|
-
|
406
|
-
# Create feed item
|
407
|
-
@item = mock
|
408
|
-
@item.stubs(:[]).with(:title).returns(nil)
|
409
|
-
@item.stubs(:[]).with(:author_name).returns(nil)
|
410
|
-
@item.stubs(:[]).with(:author_uri).returns(nil)
|
411
|
-
@item.stubs(:[]).with(:[]).with(:feed_url).returns('http://example.com/feed')
|
412
|
-
|
413
|
-
# Check
|
414
|
-
atom_feed
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
def test_atom_feed_with_articles_param
|
419
|
-
if_have 'builder' do
|
420
|
-
# Mock items
|
421
|
-
@items = [ mock, mock, mock, mock, mock ]
|
422
|
-
@items[0].stubs(:[]).with(:kind).returns('article')
|
423
|
-
@items[1].stubs(:[]).with(:kind).returns('article')
|
424
|
-
@items[2].stubs(:[]).with(:kind).returns('article')
|
425
|
-
@items[3].stubs(:[]).with(:kind).returns('article')
|
426
|
-
@items[4].stubs(:[]).with(:kind).returns('article')
|
427
|
-
|
428
|
-
# Mock one article
|
429
|
-
@items[4].stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
430
|
-
@items[4].stubs(:raw_content).returns('item 1 content')
|
431
|
-
@items[4].stubs(:[]).with(:created_at).returns((Time.now - 1000).to_s)
|
432
|
-
@items[4].stubs(:[]).with(:title).returns('Item One')
|
433
|
-
@items[4].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
434
|
-
@items[4].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
435
|
-
@items[4].stubs(:[]).with(:path).returns('/item1/')
|
436
|
-
@items[4].stubs(:[]).with(:excerpt).returns(nil)
|
437
|
-
@items[4].stubs(:path).returns('/asdf/fdsa/')
|
438
|
-
@items[4].stubs(:raw_path).returns('output/asdf/fdsa/index.html')
|
439
|
-
@items[4].expects(:compiled_content).with(:snapshot => :pre).returns('asdf')
|
440
|
-
|
441
|
-
# Mock site
|
442
|
-
@site = mock
|
443
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
444
|
-
|
445
|
-
# Create feed item
|
446
|
-
@item = mock
|
447
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
448
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
449
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
450
|
-
@item.stubs(:[]).with(:[]).with(:feed_url).returns('http://example.com/feed')
|
451
|
-
|
452
|
-
# Check
|
453
|
-
atom_feed :articles => [ @items[4] ]
|
454
|
-
end
|
455
|
-
end
|
456
|
-
|
457
|
-
def test_atom_feed_with_limit_param
|
458
|
-
if_have 'builder' do
|
459
|
-
# Mock articles
|
460
|
-
@items = [ mock, mock, mock, mock, mock ]
|
461
|
-
@items.each_with_index do |article, i|
|
462
|
-
article.stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
463
|
-
article.stubs(:[]).with(:kind).returns('article')
|
464
|
-
article.stubs(:[]).with(:created_at).returns((Time.now - 1000*i).to_s)
|
465
|
-
article.stubs(:[]).with(:title).returns("Article #{i}")
|
466
|
-
article.stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
467
|
-
article.stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
468
|
-
article.stubs(:[]).with(:path).returns("/articles/#{i}/")
|
469
|
-
article.stubs(:[]).with(:excerpt).returns(nil)
|
470
|
-
article.stubs(:path).returns("/articles/#{i}/")
|
471
|
-
article.stubs(:raw_path).returns("output/articles/#{i}/index.html")
|
472
|
-
article.stubs(:compiled_content).with(:snapshot => :pre).returns("item #{i} content")
|
473
|
-
end
|
474
|
-
|
475
|
-
# Mock site
|
476
|
-
@site = mock
|
477
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
478
|
-
|
479
|
-
# Create feed item
|
480
|
-
@item = mock
|
481
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
482
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
483
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
484
|
-
@item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
|
485
|
-
|
486
|
-
# Check
|
487
|
-
result = atom_feed :limit => 3, :articles => @items
|
488
|
-
assert_match(
|
489
|
-
Regexp.new('Article 0.*Article 1.*Article 2', Regexp::MULTILINE),
|
490
|
-
result
|
491
|
-
)
|
492
|
-
end
|
493
|
-
end
|
494
|
-
|
495
|
-
def test_atom_feed_sorting
|
496
|
-
if_have 'builder' do
|
497
|
-
# Mock articles
|
498
|
-
@items = [ mock, mock, mock, mock ]
|
499
|
-
@items.each_with_index do |article, i|
|
500
|
-
article.stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
501
|
-
article.stubs(:[]).with(:kind).returns('article')
|
502
|
-
article.stubs(:[]).with(:title).returns("Article #{i}")
|
503
|
-
article.stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
504
|
-
article.stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
505
|
-
article.stubs(:[]).with(:path).returns("/articles/#{i}/")
|
506
|
-
article.stubs(:[]).with(:excerpt).returns(nil)
|
507
|
-
article.stubs(:path).returns("/articles/#{i}/")
|
508
|
-
article.stubs(:raw_path).returns("output/articles/#{i}/index.html")
|
509
|
-
article.stubs(:compiled_content).with(:snapshot => :pre).returns("Article #{i} content")
|
510
|
-
end
|
511
|
-
@items[0].stubs(:[]).with(:created_at).returns('23-02-2009')
|
512
|
-
@items[1].stubs(:[]).with(:created_at).returns('22-03-2009')
|
513
|
-
@items[2].stubs(:[]).with(:created_at).returns('21-04-2009')
|
514
|
-
@items[3].stubs(:[]).with(:created_at).returns('20-05-2009')
|
515
|
-
|
516
|
-
# Mock site
|
517
|
-
@site = mock
|
518
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
519
|
-
|
520
|
-
# Create feed item
|
521
|
-
@item = mock
|
522
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
523
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
524
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
525
|
-
@item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
|
526
|
-
|
527
|
-
# Check
|
528
|
-
result = atom_feed
|
529
|
-
assert_match(
|
530
|
-
Regexp.new('Article 3.*Article 2.*Article 1.*Article 0', Regexp::MULTILINE),
|
531
|
-
result
|
532
|
-
)
|
533
|
-
end
|
534
|
-
end
|
535
|
-
|
536
|
-
def test_atom_feed_with_content_proc_param
|
537
|
-
if_have 'builder' do
|
538
|
-
# Mock article
|
539
|
-
@items = [ mock ]
|
540
|
-
@items[0].stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
541
|
-
@items[0].stubs(:[]).with(:kind).returns('article')
|
542
|
-
@items[0].stubs(:[]).with(:created_at).returns((Time.now - 1000).to_s)
|
543
|
-
@items[0].stubs(:[]).with(:title).returns('Item One')
|
544
|
-
@items[0].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
545
|
-
@items[0].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
546
|
-
@items[0].stubs(:[]).with(:excerpt).returns(nil)
|
547
|
-
@items[0].stubs(:path).returns('/item1/')
|
548
|
-
@items[0].stubs(:raw_path).returns('output/item1/index.html')
|
549
|
-
|
550
|
-
# Mock site
|
551
|
-
@site = mock
|
552
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
553
|
-
|
554
|
-
# Create feed item
|
555
|
-
@item = mock
|
556
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
557
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
558
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
559
|
-
@item.stubs(:[]).with(:feed_url).returns('http://example.com/feed')
|
560
|
-
|
561
|
-
# Check
|
562
|
-
result = atom_feed :content_proc => lambda { |a| 'foobar!' }
|
563
|
-
assert_match 'foobar!</content>', result
|
564
|
-
end
|
565
|
-
end
|
566
|
-
|
567
|
-
def test_atom_feed_with_excerpt_proc_param
|
568
|
-
if_have 'builder' do
|
569
|
-
# Mock article
|
570
|
-
@items = [ mock ]
|
571
|
-
@items[0].stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
572
|
-
@items[0].stubs(:[]).with(:kind).returns('article')
|
573
|
-
@items[0].stubs(:[]).with(:created_at).returns((Time.now - 1000).to_s)
|
574
|
-
@items[0].stubs(:[]).with(:title).returns('Item One')
|
575
|
-
@items[0].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
576
|
-
@items[0].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
577
|
-
@items[0].stubs(:raw_content).returns('some content')
|
578
|
-
@items[0].stubs(:path).returns('/item1/')
|
579
|
-
@items[0].stubs(:raw_path).returns('output/item1/index.html')
|
580
|
-
@items[0].expects(:compiled_content).with(:snapshot => :pre).returns('foo')
|
581
|
-
|
582
|
-
# Mock site
|
583
|
-
@site = mock
|
584
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
585
|
-
|
586
|
-
# Create feed item
|
587
|
-
@item = mock
|
588
|
-
@item.stubs(:[]).with(:title).returns('My Blog Or Something')
|
589
|
-
@item.stubs(:[]).with(:author_name).returns('J. Doe')
|
590
|
-
@item.stubs(:[]).with(:author_uri).returns('http://example.com/~jdoe')
|
591
|
-
@item.stubs(:[]).with(:[]).with(:feed_url).returns('http://example.com/feed')
|
592
|
-
|
593
|
-
# Check
|
594
|
-
result = atom_feed :excerpt_proc => lambda { |a| 'foobar!' }
|
595
|
-
assert_match 'foobar!</summary>', result
|
596
|
-
end
|
597
|
-
end
|
598
|
-
|
599
|
-
def test_atom_feed_with_item_without_path
|
600
|
-
if_have 'builder' do
|
601
|
-
# Create items
|
602
|
-
@items = [ mock ]
|
603
|
-
@items[0].stubs(:[]).with(:updated_at).returns(Time.now - 500)
|
604
|
-
@items[0].stubs(:identifier).returns('/item/')
|
605
|
-
@items[0].stubs(:[]).with(:kind).returns('article')
|
606
|
-
@items[0].stubs(:[]).with(:created_at).returns((Time.now - 1000).to_s)
|
607
|
-
@items[0].stubs(:[]).with(:title).returns('Item One')
|
608
|
-
@items[0].stubs(:[]).with(:custom_path_in_feed).returns(nil)
|
609
|
-
@items[0].stubs(:[]).with(:custom_url_in_feed).returns(nil)
|
610
|
-
@items[0].stubs(:[]).with(:excerpt).returns(nil)
|
611
|
-
@items[0].stubs(:path).returns(nil)
|
612
|
-
|
613
|
-
# Mock site
|
614
|
-
@site = mock
|
615
|
-
@site.stubs(:config).returns({ :base_url => 'http://example.com' })
|
616
|
-
|
617
|
-
# Create feed item
|
618
|
-
@item = mock
|
619
|
-
@item.stubs(:identifier).returns('/feed/')
|
620
|
-
@item.stubs(:[]).with(:title).returns('My Cool Blog')
|
621
|
-
@item.stubs(:[]).with(:author_name).returns('Denis Defreyne')
|
622
|
-
@item.stubs(:[]).with(:author_uri).returns('http://stoneship.org/')
|
623
|
-
@item.stubs(:[]).with(:feed_url).returns(nil)
|
624
|
-
@item.stubs(:path).returns("/journal/feed/")
|
625
|
-
|
626
|
-
# Check
|
627
|
-
atom_feed
|
628
|
-
end
|
629
|
-
end
|
630
|
-
|
631
|
-
def test_url_for_without_custom_path_in_feed
|
632
|
-
# Create site
|
633
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
634
|
-
|
635
|
-
# Create article
|
636
|
-
item = Nanoc3::Item.new('content', {}, '/foo/')
|
637
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
638
|
-
item.reps[0].path = '/foo/bar/'
|
639
|
-
|
640
|
-
# Check
|
641
|
-
assert_equal('http://example.com/foo/bar/', url_for(item))
|
642
|
-
ensure
|
643
|
-
# Cleanup
|
644
|
-
@item = nil
|
645
|
-
end
|
646
|
-
|
647
|
-
def test_url_for_with_custom_path_in_feed
|
648
|
-
# Create site
|
649
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
650
|
-
|
651
|
-
# Create article
|
652
|
-
item = Nanoc3::Item.new(
|
653
|
-
'content', { :custom_path_in_feed => '/meow/woof/' }, '/foo/')
|
654
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
655
|
-
|
656
|
-
# Check
|
657
|
-
assert_equal('http://example.com/meow/woof/', url_for(item))
|
658
|
-
ensure
|
659
|
-
# Cleanup
|
660
|
-
@item = nil
|
661
|
-
end
|
662
|
-
|
663
|
-
def test_url_for_with_custom_url_in_feed
|
664
|
-
# Create site
|
665
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
666
|
-
|
667
|
-
# Create article
|
668
|
-
item = Nanoc3::Item.new(
|
669
|
-
'content', { :custom_url_in_feed => 'http://example.org/x' }, '/foo/')
|
670
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
671
|
-
|
672
|
-
# Check
|
673
|
-
assert_equal('http://example.org/x', url_for(item))
|
674
|
-
ensure
|
675
|
-
# Cleanup
|
676
|
-
@item = nil
|
677
|
-
end
|
678
|
-
|
679
|
-
def test_url_for_without_base_url
|
680
|
-
# Create site
|
681
|
-
@site = Nanoc3::Site.new({})
|
682
|
-
|
683
|
-
# Check
|
684
|
-
assert_raises(RuntimeError) do
|
685
|
-
url_for(nil)
|
686
|
-
end
|
687
|
-
end
|
688
|
-
|
689
|
-
def test_url_for_without_path
|
690
|
-
# Create site
|
691
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
692
|
-
|
693
|
-
# Create article
|
694
|
-
item = Nanoc3::Item.new('content', {}, '/foo/')
|
695
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
696
|
-
item.reps[0].path = nil
|
697
|
-
|
698
|
-
# Check
|
699
|
-
assert_equal(nil, url_for(item))
|
700
|
-
end
|
701
|
-
|
702
|
-
def test_feed_url_without_custom_feed_url
|
703
|
-
# Create site
|
704
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
705
|
-
|
706
|
-
# Create article
|
707
|
-
@item = Nanoc3::Item.new('content', {}, '/foo/')
|
708
|
-
@item.reps << Nanoc3::ItemRep.new(@item, :default)
|
709
|
-
@item.reps[0].path = '/foo/bar/'
|
710
|
-
|
711
|
-
# Check
|
712
|
-
assert_equal('http://example.com/foo/bar/', feed_url)
|
713
|
-
ensure
|
714
|
-
# Cleanup
|
715
|
-
@item = nil
|
716
|
-
end
|
717
|
-
|
718
|
-
def test_feed_url_with_custom_feed_url
|
719
|
-
# Create site
|
720
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
721
|
-
|
722
|
-
# Create feed item
|
723
|
-
@item = Nanoc3::Item.new('content', { :feed_url => 'http://example.com/feed/' }, '/foo/')
|
724
|
-
@item.reps << Nanoc3::ItemRep.new(@item, :default)
|
725
|
-
@item.reps[0].path = '/foo/bar/'
|
726
|
-
|
727
|
-
# Check
|
728
|
-
assert_equal('http://example.com/feed/', feed_url)
|
729
|
-
ensure
|
730
|
-
# Cleanup
|
731
|
-
@item = nil
|
732
|
-
end
|
733
|
-
|
734
|
-
def test_feed_url_without_base_url
|
735
|
-
# Create site
|
736
|
-
@site = Nanoc3::Site.new({})
|
737
|
-
|
738
|
-
# Check
|
739
|
-
assert_raises(RuntimeError) do
|
740
|
-
feed_url
|
741
|
-
end
|
742
|
-
end
|
743
|
-
|
744
|
-
def test_atom_tag_for_with_path
|
745
|
-
# Create site
|
746
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
747
|
-
|
748
|
-
# Create article
|
749
|
-
item = Nanoc3::Item.new('content', { :created_at => '2008-05-19' }, '/foo/')
|
750
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
751
|
-
item.reps[0].path = '/foo/bar/'
|
752
|
-
|
753
|
-
# Check
|
754
|
-
assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
|
755
|
-
end
|
756
|
-
|
757
|
-
def test_atom_tag_for_without_path
|
758
|
-
# Create site
|
759
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
760
|
-
|
761
|
-
# Create article
|
762
|
-
item = Nanoc3::Item.new('content', { :created_at => '2008-05-19' }, '/baz/qux/')
|
763
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
764
|
-
|
765
|
-
# Check
|
766
|
-
assert_equal('tag:example.com,2008-05-19:/baz/qux/', atom_tag_for(item))
|
767
|
-
end
|
768
|
-
|
769
|
-
def test_atom_tag_for_with_base_url_in_dir
|
770
|
-
# Create site
|
771
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com/somedir' })
|
772
|
-
|
773
|
-
# Create article
|
774
|
-
item = Nanoc3::Item.new('content', { :created_at => '2008-05-19' }, '/foo/')
|
775
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
776
|
-
item.reps[0].path = '/foo/bar/'
|
777
|
-
|
778
|
-
# Check
|
779
|
-
assert_equal('tag:example.com,2008-05-19:/somedir/foo/bar/', atom_tag_for(item))
|
780
|
-
end
|
781
|
-
|
782
|
-
def test_atom_tag_for_with_time
|
783
|
-
# Create site
|
784
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
785
|
-
|
786
|
-
# Create article
|
787
|
-
item = Nanoc3::Item.new('content', { :created_at => Time.parse('2008-05-19') }, '/foo/')
|
788
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
789
|
-
item.reps[0].path = '/foo/bar/'
|
790
|
-
|
791
|
-
# Check
|
792
|
-
assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
|
793
|
-
end
|
794
|
-
|
795
|
-
def test_atom_tag_for_with_date
|
796
|
-
# Create site
|
797
|
-
@site = Nanoc3::Site.new({ :base_url => 'http://example.com' })
|
798
|
-
|
799
|
-
# Create article
|
800
|
-
item = Nanoc3::Item.new('content', { :created_at => Date.parse('2008-05-19') }, '/foo/')
|
801
|
-
item.reps << Nanoc3::ItemRep.new(item, :default)
|
802
|
-
item.reps[0].path = '/foo/bar/'
|
803
|
-
|
804
|
-
# Check
|
805
|
-
assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
|
806
|
-
end
|
807
|
-
|
808
|
-
end
|