nanoc3 3.1.7 → 3.1.8

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