nanoc3 3.2.0a4 → 3.2.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/NEWS.md +20 -2
  2. data/README.md +7 -3
  3. data/bin/nanoc3 +1 -3
  4. data/lib/nanoc3.rb +1 -13
  5. data/lib/nanoc3/base/compilation/filter.rb +21 -0
  6. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +1 -3
  7. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +1 -1
  8. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -2
  9. data/lib/nanoc3/base/compilation/rules_collection.rb +37 -13
  10. data/lib/nanoc3/base/directed_graph.rb +3 -3
  11. data/lib/nanoc3/base/memoization.rb +6 -9
  12. data/lib/nanoc3/base/source_data/code_snippet.rb +2 -1
  13. data/lib/nanoc3/base/source_data/configuration.rb +7 -3
  14. data/lib/nanoc3/base/source_data/item.rb +52 -10
  15. data/lib/nanoc3/base/source_data/layout.rb +28 -1
  16. data/lib/nanoc3/base/source_data/site.rb +14 -3
  17. data/lib/nanoc3/cli.rb +98 -6
  18. data/lib/nanoc3/cli/{base.rb → command.rb} +117 -153
  19. data/lib/nanoc3/cli/commands/autocompile.rb +20 -48
  20. data/lib/nanoc3/cli/commands/compile.rb +32 -48
  21. data/lib/nanoc3/cli/commands/create_item.rb +21 -37
  22. data/lib/nanoc3/cli/commands/create_layout.rb +18 -36
  23. data/lib/nanoc3/cli/commands/create_site.rb +15 -34
  24. data/lib/nanoc3/cli/commands/debug.rb +17 -31
  25. data/lib/nanoc3/cli/commands/info.rb +14 -29
  26. data/lib/nanoc3/cli/commands/nanoc.rb +37 -0
  27. data/lib/nanoc3/cli/commands/update.rb +21 -44
  28. data/lib/nanoc3/cli/commands/view.rb +18 -44
  29. data/lib/nanoc3/cli/commands/watch.rb +16 -31
  30. data/lib/nanoc3/data_sources/filesystem.rb +25 -6
  31. data/lib/nanoc3/data_sources/filesystem_unified.rb +5 -5
  32. data/lib/nanoc3/extra/auto_compiler.rb +1 -0
  33. data/lib/nanoc3/extra/file_proxy.rb +0 -1
  34. data/lib/nanoc3/filters.rb +2 -0
  35. data/lib/nanoc3/filters/asciidoc.rb +16 -36
  36. data/lib/nanoc3/filters/bluecloth.rb +2 -2
  37. data/lib/nanoc3/filters/coderay.rb +2 -2
  38. data/lib/nanoc3/filters/colorize_syntax.rb +18 -5
  39. data/lib/nanoc3/filters/erb.rb +2 -2
  40. data/lib/nanoc3/filters/erubis.rb +2 -2
  41. data/lib/nanoc3/filters/haml.rb +2 -2
  42. data/lib/nanoc3/filters/kramdown.rb +2 -2
  43. data/lib/nanoc3/filters/less.rb +32 -1
  44. data/lib/nanoc3/filters/markaby.rb +2 -2
  45. data/lib/nanoc3/filters/maruku.rb +2 -2
  46. data/lib/nanoc3/filters/mustache.rb +2 -2
  47. data/lib/nanoc3/filters/rainpress.rb +2 -2
  48. data/lib/nanoc3/filters/rdiscount.rb +4 -3
  49. data/lib/nanoc3/filters/rdoc.rb +10 -6
  50. data/lib/nanoc3/filters/redcarpet.rb +2 -2
  51. data/lib/nanoc3/filters/redcloth.rb +2 -2
  52. data/lib/nanoc3/filters/rubypants.rb +2 -2
  53. data/lib/nanoc3/filters/sass.rb +44 -52
  54. data/lib/nanoc3/filters/slim.rb +2 -2
  55. data/lib/nanoc3/filters/typogruby.rb +2 -2
  56. data/lib/nanoc3/filters/uglify_js.rb +42 -0
  57. data/nanoc3.gemspec +1 -1
  58. data/tasks/test.rake +6 -0
  59. data/test/base/core_ext/array_spec.rb +0 -2
  60. data/test/base/core_ext/hash_spec.rb +0 -2
  61. data/test/base/core_ext/pathname_spec.rb +0 -2
  62. data/test/base/core_ext/string_spec.rb +0 -2
  63. data/test/base/test_checksum_store.rb +0 -2
  64. data/test/base/test_code_snippet.rb +0 -2
  65. data/test/base/test_compiler.rb +2 -4
  66. data/test/base/test_compiler_dsl.rb +1 -3
  67. data/test/base/test_context.rb +0 -2
  68. data/test/base/test_data_source.rb +0 -2
  69. data/test/base/test_dependency_tracker.rb +0 -2
  70. data/test/base/test_directed_graph.rb +0 -2
  71. data/test/base/test_filter.rb +0 -2
  72. data/test/base/test_item.rb +19 -4
  73. data/test/base/test_item_rep.rb +0 -2
  74. data/test/base/test_layout.rb +19 -4
  75. data/test/base/test_memoization.rb +39 -2
  76. data/test/base/test_notification_center.rb +0 -2
  77. data/test/base/test_outdatedness_checker.rb +31 -2
  78. data/test/base/test_plugin.rb +0 -2
  79. data/test/base/test_rule.rb +0 -2
  80. data/test/base/test_rule_context.rb +0 -2
  81. data/test/base/test_site.rb +30 -3
  82. data/test/cli/commands/test_compile.rb +24 -3
  83. data/test/cli/commands/test_create_item.rb +5 -3
  84. data/test/cli/commands/test_create_layout.rb +4 -4
  85. data/test/cli/commands/test_create_site.rb +5 -5
  86. data/test/cli/commands/test_help.rb +3 -3
  87. data/test/cli/commands/test_info.rb +2 -3
  88. data/test/cli/commands/test_update.rb +0 -2
  89. data/test/cli/test_cli.rb +40 -0
  90. data/test/cli/test_logger.rb +0 -2
  91. data/test/data_sources/test_filesystem.rb +0 -2
  92. data/test/data_sources/test_filesystem_unified.rb +32 -58
  93. data/test/data_sources/test_filesystem_verbose.rb +0 -2
  94. data/test/extra/core_ext/test_enumerable.rb +0 -2
  95. data/test/extra/core_ext/test_time.rb +0 -2
  96. data/test/extra/deployers/test_rsync.rb +0 -2
  97. data/test/extra/test_auto_compiler.rb +5 -7
  98. data/test/extra/test_file_proxy.rb +0 -2
  99. data/test/extra/test_vcs.rb +0 -2
  100. data/test/extra/validators/test_links.rb +0 -2
  101. data/test/extra/validators/test_w3c.rb +0 -2
  102. data/test/filters/test_asciidoc.rb +0 -2
  103. data/test/filters/test_bluecloth.rb +0 -2
  104. data/test/filters/test_coderay.rb +0 -2
  105. data/test/filters/test_colorize_syntax.rb +49 -2
  106. data/test/filters/test_erb.rb +0 -2
  107. data/test/filters/test_erubis.rb +0 -2
  108. data/test/filters/test_haml.rb +0 -2
  109. data/test/filters/test_kramdown.rb +0 -2
  110. data/test/filters/test_less.rb +59 -5
  111. data/test/filters/test_markaby.rb +0 -2
  112. data/test/filters/test_maruku.rb +0 -2
  113. data/test/filters/test_mustache.rb +0 -2
  114. data/test/filters/test_rainpress.rb +0 -2
  115. data/test/filters/test_rdiscount.rb +0 -2
  116. data/test/filters/test_rdoc.rb +0 -2
  117. data/test/filters/test_redcarpet.rb +0 -2
  118. data/test/filters/test_redcloth.rb +0 -2
  119. data/test/filters/test_relativize_paths.rb +77 -24
  120. data/test/filters/test_rubypants.rb +0 -2
  121. data/test/filters/test_sass.rb +136 -10
  122. data/test/filters/test_slim.rb +0 -2
  123. data/test/filters/test_typogruby.rb +0 -2
  124. data/test/filters/test_uglify_js.rb +30 -0
  125. data/test/gem_loader.rb +11 -0
  126. data/test/helper.rb +3 -0
  127. data/test/helpers/test_blogging.rb +0 -2
  128. data/test/helpers/test_breadcrumbs.rb +0 -2
  129. data/test/helpers/test_capturing.rb +0 -2
  130. data/test/helpers/test_filtering.rb +0 -2
  131. data/test/helpers/test_html_escape.rb +0 -2
  132. data/test/helpers/test_link_to.rb +0 -2
  133. data/test/helpers/test_rendering.rb +0 -2
  134. data/test/helpers/test_tagging.rb +0 -2
  135. data/test/helpers/test_text.rb +0 -2
  136. data/test/helpers/test_xml_sitemap.rb +0 -2
  137. data/test/tasks/test_clean.rb +0 -2
  138. metadata +11 -9
  139. data/lib/nanoc3/cli/commands.rb +0 -16
  140. data/lib/nanoc3/cli/commands/help.rb +0 -71
  141. data/tasks/clean.rake +0 -11
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'redcloth'
4
+
3
5
  module Nanoc3::Filters
4
6
  class RedCloth < Nanoc3::Filter
5
7
 
@@ -24,8 +26,6 @@ module Nanoc3::Filters
24
26
  #
25
27
  # @return [String] The filtered content
26
28
  def run(content, params={})
27
- require 'redcloth'
28
-
29
29
  # Create formatter
30
30
  r = ::RedCloth.new(content)
31
31
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'rubypants'
4
+
3
5
  module Nanoc3::Filters
4
6
  class RubyPants < Nanoc3::Filter
5
7
 
@@ -10,8 +12,6 @@ module Nanoc3::Filters
10
12
  #
11
13
  # @return [String] The filtered content
12
14
  def run(content, params={})
13
- require 'rubypants'
14
-
15
15
  # Get result
16
16
  ::RubyPants.new(content).to_html
17
17
  end
@@ -1,8 +1,38 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'sass'
4
+ require 'set'
5
+
3
6
  module Nanoc3::Filters
4
7
  class Sass < Nanoc3::Filter
5
8
 
9
+ class << self
10
+ # The current filter. This is definitely going to bite me if I ever get
11
+ # to multithreading nanoc.
12
+ attr_accessor :current
13
+ end
14
+
15
+ # Essentially the {Sass::Importers::Filesystem} but registering each
16
+ # import file path.
17
+ class SassFilesystemImporter < ::Sass::Importers::Filesystem
18
+
19
+ private
20
+
21
+ def _find(dir, name, options)
22
+ full_filename, syntax = find_real_file(dir, name)
23
+ return unless full_filename && File.readable?(full_filename)
24
+
25
+ filter = Nanoc3::Filters::Sass.current
26
+ item = filter.imported_filename_to_item(full_filename)
27
+ filter.depend_on([ item ]) unless item.nil?
28
+
29
+ options[:syntax] = syntax
30
+ options[:filename] = full_filename
31
+ options[:importer] = self
32
+ ::Sass::Engine.new(File.read(full_filename), options)
33
+ end
34
+ end
35
+
6
36
  # Runs the content through [Sass](http://sass-lang.com/).
7
37
  # Parameters passed to this filter will be passed on to Sass.
8
38
  #
@@ -10,64 +40,26 @@ module Nanoc3::Filters
10
40
  #
11
41
  # @return [String] The filtered content
12
42
  def run(content, params={})
13
- require 'sass'
14
-
15
- # Add imported_filename read accessor to ImportNode
16
- # … but… but… nex3 said I could monkey patch it! :(
17
- methods = ::Sass::Tree::ImportNode.instance_methods
18
- if !methods.include?(:import_filename) && !methods.include?('import_filename')
19
- ::Sass::Tree::ImportNode.send(:attr_reader, :imported_filename)
20
- end
21
-
22
- # Get options
43
+ # Build options
23
44
  options = params.dup
24
- sass_filename = options[:filename] || (@item && @item[:content_filename])
45
+ sass_filename = options[:filename] ||
46
+ (@item && @item[:content_filename])
25
47
  options[:filename] ||= sass_filename
48
+ options[:filesystem_importer] ||=
49
+ Nanoc3::Filters::Sass::SassFilesystemImporter
26
50
 
27
- # Build engine
51
+ # Render
28
52
  engine = ::Sass::Engine.new(content, options)
53
+ self.class.current = self
54
+ engine.render
55
+ end
29
56
 
30
- # Get import nodes
31
- imported_nodes = []
32
- unprocessed_nodes = Set.new([ engine.to_tree ])
33
- until unprocessed_nodes.empty?
34
- # Get an unprocessed node
35
- node = unprocessed_nodes.each { |n| break n }
36
- unprocessed_nodes.delete(node)
37
-
38
- # Add to list of import nodes if necessary
39
- imported_nodes << node if node.is_a?(::Sass::Tree::ImportNode)
40
-
41
- # Mark children of this node for processing
42
- node.children.each { |c| unprocessed_nodes << c }
43
- end
44
-
45
- # Get import paths
46
- import_paths = (options[:load_paths] || []).dup
47
- import_paths.unshift(File.dirname(sass_filename)) if sass_filename
48
- imported_filenames = imported_nodes.map { |node| node.imported_filename }
49
-
50
- # Convert to items
51
- imported_items = imported_filenames.map do |filename|
52
- pathname = Pathname.new(filename)
53
- next unless pathname.file?
54
- normalized_filename = pathname.realpath
55
- @items.find { |i| i[:content_filename] && Pathname.new(i[:content_filename]).realpath == normalized_filename }
56
- end.compact
57
-
58
- # Require compilation of each item
59
- imported_items.each do |item|
60
- # Notify
61
- Nanoc3::NotificationCenter.post(:visit_started, item)
62
- Nanoc3::NotificationCenter.post(:visit_ended, item)
63
-
64
- # Raise unmet dependency error if item is not yet compiled
65
- any_uncompiled_rep = item.reps.find { |r| !r.compiled? }
66
- raise Nanoc3::Errors::UnmetDependency.new(any_uncompiled_rep) if any_uncompiled_rep
57
+ def imported_filename_to_item(filename)
58
+ path = Pathname.new(filename).realpath
59
+ @items.find do |i|
60
+ next if i[:content_filename].nil?
61
+ Pathname.new(i[:content_filename]).realpath == path
67
62
  end
68
-
69
- # Done
70
- engine.render
71
63
  end
72
64
 
73
65
  end
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'slim'
4
+
3
5
  module Nanoc3::Filters
4
6
 
5
7
  # @since 3.2.0
@@ -12,8 +14,6 @@ module Nanoc3::Filters
12
14
  #
13
15
  # @return [String] The filtered content
14
16
  def run(content, params={})
15
- require 'slim'
16
-
17
17
  # Create context
18
18
  context = ::Nanoc3::Context.new(assigns)
19
19
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'typogruby'
4
+
3
5
  module Nanoc3::Filters
4
6
 
5
7
  # @since 3.2.0
@@ -12,8 +14,6 @@ module Nanoc3::Filters
12
14
  #
13
15
  # @return [String] The filtered content
14
16
  def run(content, params={})
15
- require 'typogruby'
16
-
17
17
  # Get result
18
18
  ::Typogruby.improve(content)
19
19
  end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'uglifier'
4
+
5
+ module Nanoc3::Filters
6
+ class UglifyJS < Nanoc3::Filter
7
+
8
+ # Runs the content through [UglifyJS](https://github.com/mishoo/UglifyJS/).
9
+ # This method optionally takes options to pass directly to Uglifier:
10
+ #
11
+ # {
12
+ # :mangle => true, # Mangle variables names
13
+ # :toplevel => false, # Mangle top-level variable names
14
+ # :except => [], # Variable names to be excluded from mangling
15
+ # :max_line_length => 32 * 1024, # Maximum line length
16
+ # :squeeze => true, # Squeeze code resulting in smaller, but less-readable code
17
+ # :seqs => true, # Reduce consecutive statements in blocks into single statement
18
+ # :dead_code => true, # Remove dead code (e.g. after return)
19
+ # :unsafe => false, # Optimizations known to be unsafe in some situations
20
+ # :copyright => true, # Show copyright message
21
+ # :beautify => false, # Ouput indented code
22
+ # :beautify_options => {
23
+ # :indent_level => 4,
24
+ # :indent_start => 0,
25
+ # :quote_keys => false,
26
+ # :space_colon => 0,
27
+ # :ascii_only => false
28
+ # }
29
+ # }
30
+ #
31
+ # @param [String] content The content to filter
32
+ #
33
+ # @option params [Array] :options ([]) A list of options to pass on to Uglifier
34
+ #
35
+ # @return [String] The filtered content
36
+ def run(content, params={})
37
+ # Add filename to load path
38
+ Uglifier.new(params).compile(content)
39
+ end
40
+
41
+ end
42
+ end
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.rdoc_options = [ '--main', 'README.md' ]
24
24
  s.extra_rdoc_files = [ 'ChangeLog', 'LICENSE', 'README.md', 'NEWS.md' ]
25
25
 
26
- s.add_runtime_dependency('cri', '>= 1.0.0')
26
+ s.add_runtime_dependency('cri', '~> 2.0')
27
27
 
28
28
  s.post_install_message = %q{------------------------------------------------------------------------------
29
29
  Thanks for installing nanoc 3.2! Here are some resources to help you get
@@ -11,6 +11,9 @@ test = namespace :test do
11
11
 
12
12
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
13
13
 
14
+ # require our test helper so we don't have to in each individual test
15
+ require 'test/helper'
16
+
14
17
  MiniTest::Unit.autorun
15
18
 
16
19
  test_files = Dir['test/**/*_spec.rb'] + Dir['test/**/test_*.rb']
@@ -25,6 +28,9 @@ test = namespace :test do
25
28
 
26
29
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/..'))
27
30
 
31
+ # require our test helper so we don't have to in each individual test
32
+ require 'test/helper'
33
+
28
34
  MiniTest::Unit.autorun
29
35
 
30
36
  test_files = Dir["test/#{dir}/**/*_spec.rb"] + Dir["test/#{dir}/**/test_*.rb"]
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  describe 'Array#symbolize_keys' do
6
4
 
7
5
  it 'should convert keys to symbols' do
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  describe 'Hash#symbolize_keys' do
6
4
 
7
5
  it 'should convert keys to symbols' do
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  describe 'Pathname#checksum' do
6
4
 
7
5
  it 'should work on empty files' do
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  describe 'String#cleaned_identifier' do
6
4
 
7
5
  it 'should not convert already clean paths' do
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::ChecksumStoreTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::CodeSnippetTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::CompilerTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -256,7 +254,7 @@ class Nanoc3::CompilerTest < MiniTest::Unit::TestCase
256
254
 
257
255
  def test_disallow_routes_not_starting_with_slash
258
256
  # Create site
259
- Nanoc3::CLI::Base.new.run([ 'create_site', 'bar' ])
257
+ Nanoc3::CLI.run %w( create_site bar)
260
258
 
261
259
  FileUtils.cd('bar') do
262
260
  # Create routes
@@ -283,7 +281,7 @@ class Nanoc3::CompilerTest < MiniTest::Unit::TestCase
283
281
 
284
282
  def test_load_should_be_idempotent
285
283
  # Create site
286
- Nanoc3::CLI::Base.new.run([ 'create_site', 'bar' ])
284
+ Nanoc3::CLI.run %w( create_site bar)
287
285
 
288
286
  FileUtils.cd('bar') do
289
287
  site = Nanoc3::Site.new('.')
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::CompilerDSLTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -20,7 +18,7 @@ class Nanoc3::CompilerDSLTest < MiniTest::Unit::TestCase
20
18
 
21
19
  def test_passthrough
22
20
  # Create site
23
- Nanoc3::CLI::Base.new.run([ 'create_site', 'bar' ])
21
+ Nanoc3::CLI.run %w( create_site bar)
24
22
  FileUtils.cd('bar') do
25
23
  # Create rep
26
24
  item = Nanoc3::Item.new('foo', { :extension => 'bar' }, '/foo/')
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::ContextTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::DataSourceTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::DependencyTrackerTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::DirectedGraphTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::FilterTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::ItemTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers
@@ -22,10 +20,14 @@ class Nanoc3::ItemTest < MiniTest::Unit::TestCase
22
20
  def test_frozen_identifier
23
21
  item = Nanoc3::Item.new("foo", {}, '/foo')
24
22
 
25
- error = assert_raises(RuntimeError) do
23
+ raised = false
24
+ begin
26
25
  item.identifier.chop!
26
+ rescue => error
27
+ raised = true
28
+ assert_equal "can't modify frozen string", error.message
27
29
  end
28
- assert_equal "can't modify frozen string", error.message
30
+ assert raised, 'Should have raised when trying to modify a frozen string'
29
31
  end
30
32
 
31
33
  def test_lookup
@@ -161,4 +163,17 @@ class Nanoc3::ItemTest < MiniTest::Unit::TestCase
161
163
  assert raised
162
164
  end
163
165
 
166
+ def test_dump_and_load
167
+ item = Nanoc3::Item.new(
168
+ "foobar",
169
+ { :a => { :b => 123 }},
170
+ '/foo/')
171
+
172
+ item = Marshal.load(Marshal.dump(item))
173
+
174
+ assert_equal '/foo/', item.identifier
175
+ assert_equal 'foobar', item.raw_content
176
+ assert_equal({ :a => { :b => 123 }}, item.attributes)
177
+ end
178
+
164
179
  end
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'test/helper'
4
-
5
3
  class Nanoc3::ItemRepTest < MiniTest::Unit::TestCase
6
4
 
7
5
  include Nanoc3::TestHelpers