nanoc3 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,417 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_handle_request_with_item_rep_with_index_filename
8
- if_have 'mime/types', 'rack' do
9
- # Create site
10
- Nanoc3::CLI.run %w( create_site bar)
11
-
12
- FileUtils.cd('bar') do
13
- # Create item
14
- FileUtils.mkdir_p('content/foo')
15
- File.open('content/foo/index.html', 'w') do |io|
16
- io.write "Moo!"
17
- end
18
-
19
- # Create output file
20
- FileUtils.mkdir_p('output/foo')
21
- File.open('output/foo/index.html', 'w') do |io|
22
- io.write "Compiled moo!"
23
- end
24
-
25
- # Create site
26
- site = Nanoc3::Site.new('.')
27
- site.expects(:compile)
28
-
29
- # Create autocompiler
30
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
31
- autocompiler.stubs(:build_site)
32
- autocompiler.stubs(:site).returns(site)
33
-
34
- # Serve
35
- status, headers, body = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/foo/index.html') }
36
-
37
- # Check response
38
- assert_equal(200, status)
39
- assert_equal('text/html', headers['Content-Type'])
40
- body.each do |b|
41
- assert_equal "Compiled moo!", b
42
- end
43
- end
44
- end
45
- end
46
-
47
- def test_handle_request_with_broken_url
48
- if_have 'mime/types', 'rack' do
49
- # Create site
50
- Nanoc3::CLI.run %w( create_site bar)
51
-
52
- FileUtils.cd('bar') do
53
- # Create site
54
- site = Nanoc3::Site.new('.')
55
-
56
- # Create autocompiler
57
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
58
- autocompiler.stubs(:build_site)
59
- autocompiler.stubs(:site).returns(site)
60
-
61
- # Serve
62
- status, headers, body = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/afjwiagoawf.html') }
63
-
64
- # Check response
65
- assert_equal(404, status)
66
- end
67
- end
68
- end
69
-
70
- def test_handle_request_with_file
71
- if_have 'rack' do
72
- # Create file
73
- FileUtils.mkdir_p('out')
74
- File.open('out/somefile.txt', 'w') { |io| io.write('hello') }
75
-
76
- # Create file server
77
- file_server = mock
78
- def file_server.call(env)
79
- @expected_path_info = 'somefile.txt'
80
- @actual_path_info = env['PATH_INFO']
81
- end
82
- def file_server.expected_path_info ; @expected_path_info ; end
83
- def file_server.actual_path_info ; @actual_path_info ; end
84
-
85
- # Create site
86
- site = mock
87
- site.expects(:items).returns([])
88
- site.expects(:config).returns({ :output_dir => 'out', :index_filenames => [ 'index.html' ] })
89
-
90
- # Create autocompiler
91
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
92
- autocompiler.stubs(:build_site)
93
- autocompiler.stubs(:site).returns(site)
94
- autocompiler.expects(:file_server).returns(file_server)
95
-
96
- # Run
97
- autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'somefile.txt') }
98
-
99
- # Check
100
- assert_equal(file_server.expected_path_info, file_server.actual_path_info)
101
- end
102
- end
103
-
104
- def test_handle_request_with_dir_with_slash_with_index_file
105
- if_have 'rack' do
106
- # Create file
107
- FileUtils.mkdir_p('out/foo/bar')
108
- File.open('out/foo/bar/index.html', 'w') { |io| io.write('hello') }
109
-
110
- # Create file server
111
- file_server = mock
112
- def file_server.call(env)
113
- @expected_path_info = '/foo/bar/index.html'
114
- @actual_path_info = env['PATH_INFO']
115
- end
116
- def file_server.expected_path_info ; @expected_path_info ; end
117
- def file_server.actual_path_info ; @actual_path_info ; end
118
-
119
- # Create site
120
- site = mock
121
- site.expects(:items).returns([])
122
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => [ 'index.html' ] })
123
-
124
- # Create autocompiler
125
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
126
- autocompiler.stubs(:build_site)
127
- autocompiler.stubs(:site).returns(site)
128
- autocompiler.expects(:file_server).returns(file_server)
129
-
130
- # Run
131
- autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/foo/bar/') }
132
-
133
- # Check
134
- assert_equal(file_server.expected_path_info, file_server.actual_path_info)
135
- end
136
- end
137
-
138
- def test_handle_request_with_dir_with_slash_without_index_file
139
- if_have 'rack' do
140
- # Create file
141
- FileUtils.mkdir_p('out/foo/bar')
142
- File.open('out/foo/bar/someotherfile.txt', 'w') { |io| io.write('hello') }
143
-
144
- # Create file server
145
- file_server = mock
146
- def file_server.call(env)
147
- @expected_path_info = 'foo/bar/'
148
- @actual_path_info = env['PATH_INFO']
149
- end
150
- def file_server.expected_path_info ; @expected_path_info ; end
151
- def file_server.actual_path_info ; @actual_path_info ; end
152
-
153
- # Create site
154
- site = mock
155
- site.expects(:items).returns([])
156
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => [ 'index.html' ] })
157
-
158
- # Create autocompiler
159
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
160
- autocompiler.stubs(:build_site)
161
- autocompiler.stubs(:site).returns(site)
162
- autocompiler.expects(:file_server).returns(file_server)
163
-
164
- # Run
165
- autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar/') }
166
-
167
- # Check
168
- assert_equal(file_server.expected_path_info, file_server.actual_path_info)
169
- end
170
- end
171
-
172
- def test_handle_request_with_dir_without_slash_with_index_file
173
- if_have 'rack' do
174
- # Create file
175
- FileUtils.mkdir_p('out/foo/bar')
176
- File.open('out/foo/bar/index.html', 'w') { |io| io.write('hello') }
177
-
178
- # Create file server
179
- file_server = mock
180
- def file_server.call(env)
181
- @expected_path_info = 'foo/bar'
182
- @actual_path_info = env['PATH_INFO']
183
- end
184
- def file_server.expected_path_info ; @expected_path_info ; end
185
- def file_server.actual_path_info ; @actual_path_info ; end
186
-
187
- # Create site
188
- site = mock
189
- site.expects(:items).returns([])
190
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => [ 'index.html' ] })
191
-
192
- # Create autocompiler
193
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
194
- autocompiler.stubs(:build_site)
195
- autocompiler.stubs(:site).returns(site)
196
- autocompiler.expects(:file_server).returns(file_server)
197
-
198
- # Run
199
- autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar') }
200
-
201
- # Check
202
- assert_equal(file_server.expected_path_info, file_server.actual_path_info)
203
- end
204
- end
205
-
206
- def test_handle_request_with_dir_without_slash_without_index_file
207
- if_have 'rack' do
208
- # Create file
209
- FileUtils.mkdir_p('out/foo/bar')
210
- File.open('out/foo/bar/someotherfile.txt', 'w') { |io| io.write('hello') }
211
-
212
- # Create file server
213
- file_server = mock
214
- def file_server.call(env)
215
- @expected_path_info = 'foo/bar'
216
- @actual_path_info = env['PATH_INFO']
217
- end
218
- def file_server.expected_path_info ; @expected_path_info ; end
219
- def file_server.actual_path_info ; @actual_path_info ; end
220
-
221
- # Create site
222
- site = mock
223
- site.expects(:items).returns([])
224
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => [ 'index.html' ] })
225
-
226
- # Create autocompiler
227
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
228
- autocompiler.stubs(:build_site)
229
- autocompiler.stubs(:site).returns(site)
230
- autocompiler.expects(:file_server).returns(file_server)
231
-
232
- # Run
233
- autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar') }
234
-
235
- # Check
236
- assert_equal(file_server.expected_path_info, file_server.actual_path_info)
237
- end
238
- end
239
-
240
- def test_handle_request_with_404
241
- if_have 'rack' do
242
- # Create file server
243
- file_server = mock
244
- def file_server.call(env)
245
- @expected_path_info = 'four-oh-four.txt'
246
- @actual_path_info = env['PATH_INFO']
247
- end
248
- def file_server.expected_path_info ; @expected_path_info ; end
249
- def file_server.actual_path_info ; @actual_path_info ; end
250
-
251
- # Create site
252
- site = mock
253
- site.expects(:items).returns([])
254
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => [ 'index.html' ] })
255
-
256
- # Create autocompiler
257
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
258
- autocompiler.stubs(:build_site)
259
- autocompiler.stubs(:site).returns(site)
260
- autocompiler.expects(:file_server).returns(file_server)
261
-
262
- # Run
263
- autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'four-oh-four.txt') }
264
-
265
- # Check
266
- assert_equal(file_server.expected_path_info, file_server.actual_path_info)
267
- end
268
- end
269
-
270
- def test_mime_type_of
271
- if_have 'mime/types', 'rack' do
272
- # Create autocompiler
273
- autocompiler = Nanoc3::Extra::AutoCompiler.new(nil)
274
-
275
- # Create known test file
276
- File.open('foo.html', 'w') { |io| io.write('hello') }
277
- assert_equal(
278
- 'text/html',
279
- autocompiler.instance_eval { mime_type_of('foo.html', 'huh') }
280
- )
281
-
282
- # Create unknown test file
283
- File.open('foo', 'w') { |io| io.write('hello') }
284
- assert_equal(
285
- 'huh',
286
- autocompiler.instance_eval { mime_type_of('foo', 'huh') }
287
- )
288
- end
289
- end
290
-
291
- def test_serve_with_working_item
292
- if_have 'mime/types', 'rack' do
293
- # Create site
294
- Nanoc3::CLI.run %w( create_site bar)
295
-
296
- FileUtils.cd('bar') do
297
- # Create item
298
- File.open('content/index.html', 'w') do |io|
299
- io.write "Moo!"
300
- end
301
-
302
- # Create output file
303
- File.open('output/index.html', 'w') do |io|
304
- io.write "Compiled moo!"
305
- end
306
-
307
- # Create site
308
- site = Nanoc3::Site.new('.')
309
- site.expects(:compile)
310
-
311
- # Create autocompiler
312
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
313
- autocompiler.stubs(:build_site)
314
- autocompiler.stubs(:site).returns(site)
315
-
316
- # Serve
317
- status, headers, body = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/') }
318
-
319
- # Check response
320
- assert_equal(200, status)
321
- assert_equal('text/html', headers['Content-Type'])
322
- body.each do |b|
323
- assert_equal "Compiled moo!", b
324
- end
325
- end
326
- end
327
- end
328
-
329
- def test_serve_with_broken_item
330
- if_have 'mime/types', 'rack' do
331
- # Create site
332
- Nanoc3::CLI.run %w( create_site bar)
333
-
334
- FileUtils.cd('bar') do
335
- # Create item
336
- File.open('content/whatever.html', 'w') do |io|
337
- io.write "Whatever!"
338
- end
339
-
340
- # Create site
341
- site = Nanoc3::Site.new('.')
342
- site.expects(:compile).raises(RuntimeError, 'aah! fail!')
343
-
344
- # Create autocompiler
345
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
346
- autocompiler.stubs(:build_site)
347
- autocompiler.stubs(:site).returns(site)
348
-
349
- # Serve
350
- assert_raises(RuntimeError) do
351
- autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/whatever/') }
352
- end
353
- end
354
- end
355
- end
356
-
357
- def test_reload_config_file_before_each_request
358
- if_have 'rack' do
359
- # Create site
360
- Nanoc3::CLI.run %w( create_site foo )
361
-
362
- FileUtils.cd('foo') do
363
- # Create item that outputs config elements
364
- File.open('content/index.html', 'w') do |io|
365
- io.write "The Grand Value of Configuration is <%= @config[:value] %>!"
366
- end
367
-
368
- # Create autocompiler
369
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
370
-
371
- # Set config to 1st value
372
- File.open('config.yaml', 'w') do |io|
373
- io.write "value: Foo"
374
- end
375
- File.utime(Time.now+5, Time.now+5, 'config.yaml')
376
-
377
- # Check
378
- status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
379
- body.each do |b|
380
- assert_match /The Grand Value of Configuration is Foo!/, b
381
- end
382
-
383
- # Set config to 2nd value
384
- File.open('config.yaml', 'w') do |io|
385
- io.write "value: Bar"
386
- end
387
- File.utime(Time.now+5, Time.now+5, 'config.yaml')
388
-
389
- # Check
390
- status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
391
- body.each do |b|
392
- assert_match /The Grand Value of Configuration is Bar!/, b
393
- end
394
- end
395
- end
396
- end
397
-
398
- def test_call_with_uri_encoded_path
399
- if_have 'rack' do
400
- # Create autocompiler
401
- autocompiler = Nanoc3::Extra::AutoCompiler.new('.')
402
-
403
- # Mock dependencies
404
- site = mock
405
- site.stubs(:config).returns({ :output_dir => 'output/' })
406
- site.stubs(:items).returns([])
407
- autocompiler.stubs(:build_site)
408
- autocompiler.stubs(:site).returns(site)
409
-
410
- # Test
411
- result = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/%73oftware')
412
- assert_equal 404, result[0]
413
- assert_match "File not found: /software\n", result[2][0]
414
- end
415
- end
416
-
417
- end
@@ -1,19 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Extra::FileProxyTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_create_many
8
- if_implemented do
9
- # Create test file
10
- File.open('test.txt', 'w') { |io| }
11
-
12
- # Create lots of file proxies
13
- count = Process.getrlimit(Process::RLIMIT_NOFILE)[0] + 5
14
- file_proxies = []
15
- count.times { file_proxies << Nanoc3::Extra::FileProxy.new('test.txt') }
16
- end
17
- end
18
-
19
- end
@@ -1,22 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::Extra::VCSTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_named
8
- assert_nil(Nanoc3::Extra::VCS.named(:lkasjdlkfjlkasdfkj))
9
-
10
- refute_nil(Nanoc3::Extra::VCS.named(:svn))
11
- refute_nil(Nanoc3::Extra::VCS.named(:subversion))
12
- end
13
-
14
- def test_not_implemented
15
- vcs = Nanoc3::Extra::VCS.new
16
-
17
- assert_raises(NotImplementedError) { vcs.add('x') }
18
- assert_raises(NotImplementedError) { vcs.remove('x') }
19
- assert_raises(NotImplementedError) { vcs.move('x', 'y') }
20
- end
21
-
22
- end