fagiani-jekyll 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/History.txt +284 -0
  2. data/LICENSE +21 -0
  3. data/README.textile +41 -0
  4. data/Rakefile +159 -0
  5. data/bin/jekyll +192 -0
  6. data/cucumber.yml +1 -0
  7. data/features/create_sites.feature +94 -0
  8. data/features/embed_filters.feature +60 -0
  9. data/features/markdown.feature +30 -0
  10. data/features/pagination.feature +27 -0
  11. data/features/permalinks.feature +65 -0
  12. data/features/post_data.feature +153 -0
  13. data/features/site_configuration.feature +126 -0
  14. data/features/site_data.feature +82 -0
  15. data/features/step_definitions/jekyll_steps.rb +145 -0
  16. data/features/support/env.rb +16 -0
  17. data/jekyll.gemspec +140 -0
  18. data/lib/jekyll.rb +125 -0
  19. data/lib/jekyll/albino.rb +120 -0
  20. data/lib/jekyll/converter.rb +50 -0
  21. data/lib/jekyll/converters/identity.rb +22 -0
  22. data/lib/jekyll/converters/markdown.rb +113 -0
  23. data/lib/jekyll/converters/textile.rb +33 -0
  24. data/lib/jekyll/convertible.rb +98 -0
  25. data/lib/jekyll/core_ext.rb +52 -0
  26. data/lib/jekyll/errors.rb +6 -0
  27. data/lib/jekyll/filters.rb +53 -0
  28. data/lib/jekyll/generator.rb +7 -0
  29. data/lib/jekyll/generators/pagination.rb +87 -0
  30. data/lib/jekyll/layout.rb +36 -0
  31. data/lib/jekyll/migrators/csv.rb +26 -0
  32. data/lib/jekyll/migrators/drupal.rb +86 -0
  33. data/lib/jekyll/migrators/marley.rb +53 -0
  34. data/lib/jekyll/migrators/mephisto.rb +79 -0
  35. data/lib/jekyll/migrators/mt.rb +77 -0
  36. data/lib/jekyll/migrators/textpattern.rb +50 -0
  37. data/lib/jekyll/migrators/typo.rb +49 -0
  38. data/lib/jekyll/migrators/wordpress.com.rb +38 -0
  39. data/lib/jekyll/migrators/wordpress.rb +56 -0
  40. data/lib/jekyll/page.rb +134 -0
  41. data/lib/jekyll/plugin.rb +76 -0
  42. data/lib/jekyll/post.rb +244 -0
  43. data/lib/jekyll/site.rb +273 -0
  44. data/lib/jekyll/static_file.rb +75 -0
  45. data/lib/jekyll/tags/highlight.rb +73 -0
  46. data/lib/jekyll/tags/include.rb +37 -0
  47. data/test/helper.rb +34 -0
  48. data/test/source/.htaccess +8 -0
  49. data/test/source/_includes/sig.markdown +3 -0
  50. data/test/source/_layouts/default.html +27 -0
  51. data/test/source/_layouts/simple.html +1 -0
  52. data/test/source/_posts/2008-02-02-not-published.textile +8 -0
  53. data/test/source/_posts/2008-02-02-published.textile +8 -0
  54. data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
  55. data/test/source/_posts/2008-11-21-complex.textile +8 -0
  56. data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
  57. data/test/source/_posts/2008-12-13-include.markdown +8 -0
  58. data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
  59. data/test/source/_posts/2009-01-27-categories.textile +7 -0
  60. data/test/source/_posts/2009-01-27-category.textile +7 -0
  61. data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
  62. data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
  63. data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
  64. data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
  65. data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
  66. data/test/source/_posts/2009-05-18-tag.textile +6 -0
  67. data/test/source/_posts/2009-05-18-tags.textile +9 -0
  68. data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
  69. data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
  70. data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
  71. data/test/source/_posts/2010-01-09-date-override.textile +7 -0
  72. data/test/source/_posts/2010-01-09-time-override.textile +7 -0
  73. data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
  74. data/test/source/_posts/2010-01-16-override-data.textile +4 -0
  75. data/test/source/about.html +6 -0
  76. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  77. data/test/source/contacts.html +5 -0
  78. data/test/source/css/screen.css +76 -0
  79. data/test/source/deal.with.dots.html +7 -0
  80. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  81. data/test/source/index.html +22 -0
  82. data/test/source/sitemap.xml +32 -0
  83. data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
  84. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  85. data/test/suite.rb +9 -0
  86. data/test/test_configuration.rb +29 -0
  87. data/test/test_core_ext.rb +66 -0
  88. data/test/test_filters.rb +53 -0
  89. data/test/test_generated_site.rb +72 -0
  90. data/test/test_kramdown.rb +23 -0
  91. data/test/test_page.rb +117 -0
  92. data/test/test_pager.rb +113 -0
  93. data/test/test_post.rb +396 -0
  94. data/test/test_rdiscount.rb +18 -0
  95. data/test/test_site.rb +186 -0
  96. data/test/test_tags.rb +127 -0
  97. metadata +332 -0
@@ -0,0 +1,396 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestPost < Test::Unit::TestCase
4
+ def setup_post(file)
5
+ Post.new(@site, source_dir, '', file)
6
+ end
7
+
8
+ def do_render(post)
9
+ layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")}
10
+ post.render(layouts, {"site" => {"posts" => []}})
11
+ end
12
+
13
+ context "A Post" do
14
+ setup do
15
+ clear_dest
16
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
17
+ @site = Site.new(Jekyll.configuration)
18
+ end
19
+
20
+ should "ensure valid posts are valid" do
21
+ assert Post.valid?("2008-09-09-foo-bar.textile")
22
+ assert Post.valid?("foo/bar/2008-09-09-foo-bar.textile")
23
+
24
+ assert !Post.valid?("lol2008-09-09-foo-bar.textile")
25
+ assert !Post.valid?("blah")
26
+ end
27
+
28
+ context "processing posts" do
29
+ setup do
30
+ @post = Post.allocate
31
+ @post.site = @site
32
+
33
+ @real_file = "2008-10-18-foo-bar.textile"
34
+ @fake_file = "2008-09-09-foo-bar.textile"
35
+ @source = source_dir('_posts')
36
+ end
37
+
38
+ should "keep date, title, and markup type" do
39
+ @post.categories = []
40
+ @post.process(@fake_file)
41
+
42
+ assert_equal Time.parse("2008-09-09"), @post.date
43
+ assert_equal "foo-bar", @post.slug
44
+ assert_equal ".textile", @post.ext
45
+ assert_equal "/2008/09/09", @post.dir
46
+ assert_equal "/2008/09/09/foo-bar", @post.id
47
+ end
48
+
49
+ should "create url based on date and title" do
50
+ @post.categories = []
51
+ @post.process(@fake_file)
52
+ assert_equal "/2008/09/09/foo-bar.html", @post.url
53
+ end
54
+
55
+ should "CGI escape urls" do
56
+ @post.categories = []
57
+ @post.process("2009-03-12-hash-#1.markdown")
58
+ assert_equal "/2009/03/12/hash-%231.html", @post.url
59
+ assert_equal "/2009/03/12/hash-#1", @post.id
60
+ end
61
+
62
+ should "respect permalink in yaml front matter" do
63
+ file = "2008-12-03-permalinked-post.textile"
64
+ @post.process(file)
65
+ @post.read_yaml(@source, file)
66
+
67
+ assert_equal "my_category/permalinked-post", @post.permalink
68
+ assert_equal "my_category", @post.dir
69
+ assert_equal "my_category/permalinked-post", @post.url
70
+ end
71
+
72
+ context "with CRLF linebreaks" do
73
+ setup do
74
+ @real_file = "2009-05-24-yaml-linebreak.markdown"
75
+ @source = source_dir('win/_posts')
76
+ end
77
+ should "read yaml front-matter" do
78
+ @post.read_yaml(@source, @real_file)
79
+
80
+ assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data)
81
+ assert_equal "This is the content", @post.content
82
+ end
83
+ end
84
+
85
+ context "with embedded triple dash" do
86
+ setup do
87
+ @real_file = "2010-01-08-triple-dash.markdown"
88
+ end
89
+ should "consume the embedded dashes" do
90
+ @post.read_yaml(@source, @real_file)
91
+
92
+ assert_equal({"title" => "Foo --- Bar"}, @post.data)
93
+ assert_equal "Triple the fun!", @post.content
94
+ end
95
+ end
96
+
97
+ context "with site wide permalink" do
98
+ setup do
99
+ @post.categories = []
100
+ end
101
+
102
+ context "with unspecified (date) style" do
103
+ setup do
104
+ @post.process(@fake_file)
105
+ end
106
+
107
+ should "process the url correctly" do
108
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
109
+ assert_equal "/2008/09/09/foo-bar.html", @post.url
110
+ end
111
+ end
112
+
113
+ context "with unspecified (date) style and a category" do
114
+ setup do
115
+ @post.categories << "beer"
116
+ @post.process(@fake_file)
117
+ end
118
+
119
+ should "process the url correctly" do
120
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
121
+ assert_equal "/beer/2008/09/09/foo-bar.html", @post.url
122
+ end
123
+ end
124
+
125
+ context "with unspecified (date) style and categories" do
126
+ setup do
127
+ @post.categories << "food"
128
+ @post.categories << "beer"
129
+ @post.process(@fake_file)
130
+ end
131
+
132
+ should "process the url correctly" do
133
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
134
+ assert_equal "/food/beer/2008/09/09/foo-bar.html", @post.url
135
+ end
136
+ end
137
+
138
+ context "with none style" do
139
+ setup do
140
+ @post.site.permalink_style = :none
141
+ @post.process(@fake_file)
142
+ end
143
+
144
+ should "process the url correctly" do
145
+ assert_equal "/:categories/:title.html", @post.template
146
+ assert_equal "/foo-bar.html", @post.url
147
+ end
148
+ end
149
+
150
+ context "with pretty style" do
151
+ setup do
152
+ @post.site.permalink_style = :pretty
153
+ @post.process(@fake_file)
154
+ end
155
+
156
+ should "process the url correctly" do
157
+ assert_equal "/:categories/:year/:month/:day/:title/", @post.template
158
+ assert_equal "/2008/09/09/foo-bar/", @post.url
159
+ end
160
+ end
161
+
162
+ context "with custom date permalink" do
163
+ setup do
164
+ @post.site.permalink_style = '/:categories/:year/:i_month/:i_day/:title/'
165
+ @post.process(@fake_file)
166
+ end
167
+
168
+ should "process the url correctly" do
169
+ assert_equal "/2008/9/9/foo-bar/", @post.url
170
+ end
171
+ end
172
+
173
+ context "with prefix style and no extension" do
174
+ setup do
175
+ @post.site.permalink_style = "/prefix/:title"
176
+ @post.process(@fake_file)
177
+ end
178
+
179
+ should "process the url correctly" do
180
+ assert_equal "/prefix/:title", @post.template
181
+ assert_equal "/prefix/foo-bar", @post.url
182
+ end
183
+ end
184
+ end
185
+
186
+ should "read yaml front-matter" do
187
+ @post.read_yaml(@source, @real_file)
188
+
189
+ assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
190
+ assert_equal "h1. {{ page.title }}\n\nBest *post* ever", @post.content
191
+ end
192
+
193
+ should "transform textile" do
194
+ @post.process(@real_file)
195
+ @post.read_yaml(@source, @real_file)
196
+ @post.transform
197
+
198
+ assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
199
+ end
200
+ end
201
+
202
+ context "when in a site" do
203
+ setup do
204
+ clear_dest
205
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
206
+ @site = Site.new(Jekyll.configuration)
207
+ @site.posts = [setup_post('2008-02-02-published.textile'),
208
+ setup_post('2009-01-27-categories.textile')]
209
+ end
210
+
211
+ should "have next post" do
212
+ assert_equal(@site.posts.last, @site.posts.first.next)
213
+ end
214
+
215
+ should "have previous post" do
216
+ assert_equal(@site.posts.first, @site.posts.last.previous)
217
+ end
218
+
219
+ should "not have previous post if first" do
220
+ assert_equal(nil, @site.posts.first.previous)
221
+ end
222
+
223
+ should "not have next post if last" do
224
+ assert_equal(nil, @site.posts.last.next)
225
+ end
226
+ end
227
+
228
+ context "initializing posts" do
229
+ should "publish when published yaml is no specified" do
230
+ post = setup_post("2008-02-02-published.textile")
231
+ assert_equal true, post.published
232
+ end
233
+
234
+ should "not published when published yaml is false" do
235
+ post = setup_post("2008-02-02-not-published.textile")
236
+ assert_equal false, post.published
237
+ end
238
+
239
+ should "recognize date in yaml" do
240
+ post = setup_post("2010-01-09-date-override.textile")
241
+ do_render(post)
242
+ assert_equal Time, post.date.class
243
+ assert_equal Time, post.to_liquid["date"].class
244
+ assert_equal "/2010/01/10/date-override.html", post.url
245
+ assert_equal "<p>Post with a front matter date</p>\n<p>10 Jan 2010</p>", post.output
246
+ end
247
+
248
+ should "recognize time in yaml" do
249
+ post = setup_post("2010-01-09-time-override.textile")
250
+ do_render(post)
251
+ assert_equal Time, post.date.class
252
+ assert_equal Time, post.to_liquid["date"].class
253
+ assert_equal "/2010/01/10/time-override.html", post.url
254
+ assert_equal "<p>Post with a front matter time</p>\n<p>10 Jan 2010</p>", post.output
255
+ end
256
+
257
+ should "recognize time with timezone in yaml" do
258
+ post = setup_post("2010-01-09-timezone-override.textile")
259
+ do_render(post)
260
+ assert_equal Time, post.date.class
261
+ assert_equal Time, post.to_liquid["date"].class
262
+ assert_equal "/2010/01/10/timezone-override.html", post.url
263
+ assert_equal "<p>Post with a front matter time with timezone</p>\n<p>10 Jan 2010</p>", post.output
264
+ end
265
+
266
+ should "to_liquid prioritizes post attributes over data" do
267
+ post = setup_post("2010-01-16-override-data.textile")
268
+ assert_equal Array, post.tags.class
269
+ assert_equal Array, post.to_liquid["tags"].class
270
+ assert_equal Time, post.date.class
271
+ assert_equal Time, post.to_liquid["date"].class
272
+ end
273
+
274
+ should "recognize category in yaml" do
275
+ post = setup_post("2009-01-27-category.textile")
276
+ assert post.categories.include?('foo')
277
+ end
278
+
279
+ should "recognize several categories in yaml" do
280
+ post = setup_post("2009-01-27-categories.textile")
281
+ assert post.categories.include?('foo')
282
+ assert post.categories.include?('bar')
283
+ assert post.categories.include?('baz')
284
+ end
285
+
286
+ should "recognize empty category in yaml" do
287
+ post = setup_post("2009-01-27-empty-category.textile")
288
+ assert_equal [], post.categories
289
+ end
290
+
291
+ should "recognize empty categories in yaml" do
292
+ post = setup_post("2009-01-27-empty-categories.textile")
293
+ assert_equal [], post.categories
294
+ end
295
+
296
+ should "recognize tag in yaml" do
297
+ post = setup_post("2009-05-18-tag.textile")
298
+ assert post.tags.include?('code')
299
+ end
300
+
301
+ should "recognize tags in yaml" do
302
+ post = setup_post("2009-05-18-tags.textile")
303
+ assert post.tags.include?('food')
304
+ assert post.tags.include?('cooking')
305
+ assert post.tags.include?('pizza')
306
+ end
307
+
308
+ should "recognize empty tag in yaml" do
309
+ post = setup_post("2009-05-18-empty-tag.textile")
310
+ assert_equal [], post.tags
311
+ end
312
+
313
+ should "recognize empty tags in yaml" do
314
+ post = setup_post("2009-05-18-empty-tags.textile")
315
+ assert_equal [], post.tags
316
+ end
317
+
318
+ should "allow no yaml" do
319
+ post = setup_post("2009-06-22-no-yaml.textile")
320
+ assert_equal "No YAML.", post.content
321
+ end
322
+
323
+ should "allow empty yaml" do
324
+ post = setup_post("2009-06-22-empty-yaml.textile")
325
+ assert_equal "Empty YAML.", post.content
326
+ end
327
+
328
+ context "rendering" do
329
+ setup do
330
+ clear_dest
331
+ end
332
+
333
+ should "render properly" do
334
+ post = setup_post("2008-10-18-foo-bar.textile")
335
+ do_render(post)
336
+ assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
337
+ end
338
+
339
+ should "write properly" do
340
+ post = setup_post("2008-10-18-foo-bar.textile")
341
+ do_render(post)
342
+ post.write(dest_dir)
343
+
344
+ assert File.directory?(dest_dir)
345
+ assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
346
+ end
347
+
348
+ should "write properly without html extension" do
349
+ post = setup_post("2008-10-18-foo-bar.textile")
350
+ post.site.permalink_style = ":title"
351
+ do_render(post)
352
+ post.write(dest_dir)
353
+
354
+ assert File.directory?(dest_dir)
355
+ assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
356
+ end
357
+
358
+ should "insert data" do
359
+ post = setup_post("2008-11-21-complex.textile")
360
+ do_render(post)
361
+
362
+ assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: #{Time.parse("2008-11-21")}<br />\nid: /2008/11/21/complex</p> >>>", post.output
363
+ end
364
+
365
+ should "include templates" do
366
+ post = setup_post("2008-12-13-include.markdown")
367
+ post.site.source = File.join(File.dirname(__FILE__), 'source')
368
+ do_render(post)
369
+
370
+ assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
371
+ end
372
+
373
+ should "render date specified in front matter properly" do
374
+ post = setup_post("2010-01-09-date-override.textile")
375
+ do_render(post)
376
+
377
+ assert_equal "<p>Post with a front matter date</p>\n<p>10 Jan 2010</p>", post.output
378
+ end
379
+
380
+ should "render time specified in front matter properly" do
381
+ post = setup_post("2010-01-09-time-override.textile")
382
+ do_render(post)
383
+
384
+ assert_equal "<p>Post with a front matter time</p>\n<p>10 Jan 2010</p>", post.output
385
+ end
386
+
387
+ end
388
+ end
389
+
390
+ should "generate categories and topics" do
391
+ post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
392
+ assert_equal ['foo'], post.categories
393
+ end
394
+
395
+ end
396
+ end
@@ -0,0 +1,18 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestRdiscount < Test::Unit::TestCase
4
+
5
+ context "rdiscount" do
6
+ setup do
7
+ config = {
8
+ 'rdiscount' => { 'extensions' => ['smart'] },
9
+ 'markdown' => 'rdiscount'
10
+ }
11
+ @markdown = MarkdownConverter.new config
12
+ end
13
+
14
+ should "pass rdiscount extensions" do
15
+ assert_equal "<p>&ldquo;smart&rdquo;</p>", @markdown.convert('"smart"').strip
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,186 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestSite < Test::Unit::TestCase
4
+ context "creating sites" do
5
+ setup do
6
+ stub(Jekyll).configuration do
7
+ Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
8
+ end
9
+ @site = Site.new(Jekyll.configuration)
10
+ end
11
+
12
+ should "have an empty tag hash by default" do
13
+ assert_equal Hash.new, @site.tags
14
+ end
15
+
16
+ should "reset data before processing" do
17
+ clear_dest
18
+ @site.process
19
+ before_posts = @site.posts.length
20
+ before_layouts = @site.layouts.length
21
+ before_categories = @site.categories.length
22
+ before_tags = @site.tags.length
23
+ before_pages = @site.pages.length
24
+ before_static_files = @site.static_files.length
25
+ before_time = @site.time
26
+
27
+ @site.process
28
+ assert_equal before_posts, @site.posts.length
29
+ assert_equal before_layouts, @site.layouts.length
30
+ assert_equal before_categories, @site.categories.length
31
+ assert_equal before_tags, @site.tags.length
32
+ assert_equal before_pages, @site.pages.length
33
+ assert_equal before_static_files, @site.static_files.length
34
+ assert before_time <= @site.time
35
+ end
36
+
37
+ should "write only modified static files" do
38
+ clear_dest
39
+ StaticFile.reset_cache
40
+
41
+ @site.process
42
+ some_static_file = @site.static_files[0].path
43
+ dest = File.expand_path(@site.static_files[0].destination(@site.dest))
44
+ mtime1 = File.stat(dest).mtime.to_i # first run must generate dest file
45
+
46
+ # need to sleep because filesystem timestamps have best resolution in seconds
47
+ sleep 1
48
+ @site.process
49
+ mtime2 = File.stat(dest).mtime.to_i
50
+ assert_equal mtime1, mtime2
51
+
52
+ # simulate file modification by user
53
+ FileUtils.touch some_static_file
54
+
55
+ sleep 1
56
+ @site.process
57
+ mtime3 = File.stat(dest).mtime.to_i
58
+ assert_not_equal mtime2, mtime3 # must be regenerated!
59
+
60
+ sleep 1
61
+ @site.process
62
+ mtime4 = File.stat(dest).mtime.to_i
63
+ assert_equal mtime3, mtime4 # no modifications, so must be the same
64
+ end
65
+
66
+ should "write static files if not modified but missing in destination" do
67
+ clear_dest
68
+ StaticFile.reset_cache
69
+
70
+ @site.process
71
+ some_static_file = @site.static_files[0].path
72
+ dest = File.expand_path(@site.static_files[0].destination(@site.dest))
73
+ mtime1 = File.stat(dest).mtime.to_i # first run must generate dest file
74
+
75
+ # need to sleep because filesystem timestamps have best resolution in seconds
76
+ sleep 1
77
+ @site.process
78
+ mtime2 = File.stat(dest).mtime.to_i
79
+ assert_equal mtime1, mtime2
80
+
81
+ # simulate destination file deletion
82
+ File.unlink dest
83
+
84
+ sleep 1
85
+ @site.process
86
+ mtime3 = File.stat(dest).mtime.to_i
87
+ assert_not_equal mtime2, mtime3 # must be regenerated and differ!
88
+
89
+ sleep 1
90
+ @site.process
91
+ mtime4 = File.stat(dest).mtime.to_i
92
+ assert_equal mtime3, mtime4 # no modifications, so must be the same
93
+ end
94
+
95
+ should "read layouts" do
96
+ @site.read_layouts
97
+ assert_equal ["default", "simple"].sort, @site.layouts.keys.sort
98
+ end
99
+
100
+ should "read posts" do
101
+ @site.read_posts('')
102
+ posts = Dir[source_dir('_posts', '*')]
103
+ assert_equal posts.size - 1, @site.posts.size
104
+ end
105
+
106
+ should "deploy payload" do
107
+ clear_dest
108
+ @site.process
109
+
110
+ posts = Dir[source_dir("**", "_posts", "*")]
111
+ categories = %w(bar baz category foo z_category publish_test win).sort
112
+
113
+ assert_equal posts.size - 1, @site.posts.size
114
+ assert_equal categories, @site.categories.keys.sort
115
+ assert_equal 4, @site.categories['foo'].size
116
+ end
117
+
118
+ should "filter entries" do
119
+ ent1 = %w[foo.markdown bar.markdown baz.markdown #baz.markdown#
120
+ .baz.markdow foo.markdown~]
121
+ ent2 = %w[.htaccess _posts _pages bla.bla]
122
+
123
+ assert_equal %w[foo.markdown bar.markdown baz.markdown], @site.filter_entries(ent1)
124
+ assert_equal %w[.htaccess bla.bla], @site.filter_entries(ent2)
125
+ end
126
+
127
+ should "filter entries with exclude" do
128
+ excludes = %w[README TODO]
129
+ includes = %w[index.html site.css]
130
+
131
+ @site.exclude = excludes
132
+ assert_equal includes, @site.filter_entries(excludes + includes)
133
+ end
134
+
135
+ context 'with orphaned files in destination' do
136
+ setup do
137
+ clear_dest
138
+ @site.process
139
+ # generate some orphaned files:
140
+ # hidden file
141
+ File.open(dest_dir('.htpasswd'), 'w')
142
+ # single file
143
+ File.open(dest_dir('obsolete.html'), 'w')
144
+ # single file in sub directory
145
+ FileUtils.mkdir(dest_dir('qux'))
146
+ File.open(dest_dir('qux/obsolete.html'), 'w')
147
+ # empty directory
148
+ FileUtils.mkdir(dest_dir('quux'))
149
+ end
150
+
151
+ teardown do
152
+ FileUtils.rm_f(dest_dir('.htpasswd'))
153
+ FileUtils.rm_f(dest_dir('obsolete.html'))
154
+ FileUtils.rm_rf(dest_dir('qux'))
155
+ FileUtils.rm_f(dest_dir('quux'))
156
+ end
157
+
158
+ should 'remove orphaned files in destination' do
159
+ @site.process
160
+ assert !File.exist?(dest_dir('.htpasswd'))
161
+ assert !File.exist?(dest_dir('obsolete.html'))
162
+ assert !File.exist?(dest_dir('qux'))
163
+ assert !File.exist?(dest_dir('quux'))
164
+ end
165
+
166
+ end
167
+
168
+ context 'with an invalid markdown processor in the configuration' do
169
+ should 'not throw an error at initialization time' do
170
+ bad_processor = 'not a processor name'
171
+ assert_nothing_raised do
172
+ Site.new(Jekyll.configuration.merge({ 'markdown' => bad_processor }))
173
+ end
174
+ end
175
+
176
+ should 'throw FatalException at process time' do
177
+ bad_processor = 'not a processor name'
178
+ s = Site.new(Jekyll.configuration.merge({ 'markdown' => bad_processor }))
179
+ assert_raise Jekyll::FatalException do
180
+ s.process
181
+ end
182
+ end
183
+ end
184
+
185
+ end
186
+ end