nanoc 4.0.0b1 → 4.0.0b2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/NEWS.md +26 -2
  4. data/README.md +1 -1
  5. data/lib/nanoc/base.rb +3 -1
  6. data/lib/nanoc/base/checksummer.rb +1 -3
  7. data/lib/nanoc/base/compilation/compiler.rb +3 -3
  8. data/lib/nanoc/base/compilation/compiler_dsl.rb +3 -3
  9. data/lib/nanoc/base/compilation/item_rep_proxy.rb +1 -1
  10. data/lib/nanoc/base/core_ext/array.rb +0 -11
  11. data/lib/nanoc/base/core_ext/hash.rb +0 -11
  12. data/lib/nanoc/base/identifiable_collection.rb +81 -0
  13. data/lib/nanoc/base/source_data/identifier.rb +9 -9
  14. data/lib/nanoc/base/source_data/site.rb +7 -5
  15. data/lib/nanoc/base/views/identifiable_collection.rb +78 -0
  16. data/lib/nanoc/base/views/item_collection.rb +1 -86
  17. data/lib/nanoc/base/views/layout_collection.rb +1 -57
  18. data/lib/nanoc/base/views/mutable_identifiable_collection.rb +17 -0
  19. data/lib/nanoc/base/views/mutable_item_collection.rb +2 -14
  20. data/lib/nanoc/base/views/mutable_layout_collection.rb +2 -14
  21. data/lib/nanoc/cli/commands/create-site.rb +44 -40
  22. data/lib/nanoc/data_sources/filesystem.rb +1 -1
  23. data/lib/nanoc/data_sources/filesystem_unified.rb +3 -3
  24. data/lib/nanoc/data_sources/filesystem_verbose.rb +3 -3
  25. data/lib/nanoc/filters/erb.rb +2 -2
  26. data/lib/nanoc/filters/rdiscount.rb +1 -1
  27. data/lib/nanoc/filters/redcarpet.rb +1 -1
  28. data/lib/nanoc/version.rb +1 -1
  29. data/tasks/test.rake +1 -0
  30. data/test/base/core_ext/array_spec.rb +0 -8
  31. data/test/base/core_ext/hash_spec.rb +0 -26
  32. data/test/base/test_compiler.rb +1 -1
  33. data/test/base/test_compiler_dsl.rb +13 -10
  34. data/test/base/test_item.rb +0 -6
  35. data/test/base/test_item_array.rb +8 -276
  36. data/test/base/test_layout.rb +1 -5
  37. data/test/base/test_outdatedness_checker.rb +9 -2
  38. data/test/base/test_site.rb +5 -5
  39. data/test/cli/commands/test_compile.rb +14 -0
  40. data/test/cli/commands/test_create_site.rb +40 -2
  41. data/test/cli/commands/test_prune.rb +19 -4
  42. data/test/data_sources/test_filesystem.rb +1 -1
  43. data/test/data_sources/test_filesystem_unified.rb +6 -6
  44. data/test/extra/checking/checks/test_stale.rb +2 -2
  45. data/test/helper.rb +8 -1
  46. data/test/helpers/test_blogging.rb +0 -235
  47. data/test/helpers/test_breadcrumbs.rb +31 -23
  48. data/test/helpers/test_xml_sitemap.rb +38 -29
  49. metadata +5 -3
  50. data/lib/nanoc/base/source_data/item_array.rb +0 -86
@@ -3,12 +3,8 @@
3
3
  class Nanoc::Int::LayoutTest < Nanoc::TestCase
4
4
  def test_initialize
5
5
  # Make sure attributes are cleaned
6
- layout = Nanoc::Int::Layout.new('content', { 'foo' => 'bar' }, '/foo/')
6
+ layout = Nanoc::Int::Layout.new('content', { 'foo' => 'bar' }, '/foo')
7
7
  assert_equal({ foo: 'bar' }, layout.attributes)
8
-
9
- # Make sure identifier is cleaned
10
- layout = Nanoc::Int::Layout.new('content', { 'foo' => 'bar' }, 'foo')
11
- assert_equal(Nanoc::Identifier.new('/foo/'), layout.identifier)
12
8
  end
13
9
 
14
10
  def test_lookup_with_known_attribute
@@ -13,7 +13,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
13
13
  # Check
14
14
  with_site(name: 'foo') do |site|
15
15
  outdatedness_checker = site.compiler.send :outdatedness_checker
16
- rep = site.items[0].reps[0]
16
+ rep = site.items['/'].reps[0]
17
17
  assert_nil outdatedness_checker.outdatedness_reason_for(rep)
18
18
  end
19
19
  end
@@ -281,7 +281,14 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
281
281
 
282
282
  # Change code
283
283
  FileUtils.cd('foo') do
284
- File.open('nanoc.yaml', 'w') { |io| io.write('awesome: true') }
284
+ File.open('nanoc.yaml', 'w') do |io|
285
+ io << 'awesome: true' << "\n"
286
+ io << 'string_pattern_type: legacy' << "\n"
287
+ io << 'data_sources:' << "\n"
288
+ io << ' -' << "\n"
289
+ io << ' type: filesystem_unified' << "\n"
290
+ io << ' identifier_type: legacy' << "\n"
291
+ end
285
292
  end
286
293
 
287
294
  # Check
@@ -153,8 +153,8 @@ EOF
153
153
  site.load
154
154
 
155
155
  # Check
156
- assert_equal 1, site.data_sources.size
157
- assert_equal Nanoc::Identifier.new('/foo/'), site.items[0].identifier
156
+ assert_equal 1, site.data_sources.size
157
+ refute_nil site.items['/foo/']
158
158
  end
159
159
  end
160
160
 
@@ -185,7 +185,7 @@ EOF
185
185
  FileUtils.mkdir_p('content/parent')
186
186
  FileUtils.mkdir_p('content/parent/bar')
187
187
 
188
- data = File.read('nanoc.yaml').sub('identifier_style: full', 'identifier_style: stripped')
188
+ data = File.read('nanoc.yaml').sub('identifier_type: full', 'identifier_type: legacy')
189
189
  File.open('nanoc.yaml', 'w') { |io| io << data }
190
190
 
191
191
  File.open('content/parent.md', 'w') { |io| io << 'asdf' }
@@ -203,8 +203,8 @@ EOF
203
203
  qux = site.items.find { |i| i.identifier == '/parent/bar/qux/' }
204
204
 
205
205
  assert_equal Set.new([parent, style]), Set.new(root.children)
206
- assert_equal Set.new([foo, bar]), Set.new(parent.children)
207
- assert_equal Set.new([qux]), Set.new(bar.children)
206
+ assert_equal Set.new([foo, bar]), Set.new(parent.children)
207
+ assert_equal Set.new([qux]), Set.new(bar.children)
208
208
 
209
209
  assert_equal nil, root.parent
210
210
  assert_equal root, parent.parent
@@ -49,6 +49,12 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
49
49
  io.write "layout '*', :erb\n"
50
50
  end
51
51
 
52
+ File.open('nanoc.yaml', 'w') do |io|
53
+ io.write "string_pattern_type: legacy\n"
54
+ io.write "prune:\n"
55
+ io.write " auto_prune: false\n"
56
+ end
57
+
52
58
  File.open('output/stray.html', 'w') do |io|
53
59
  io.write 'I am a stray file and I am about to be deleted!'
54
60
  end
@@ -58,6 +64,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
58
64
  assert File.file?('output/stray.html')
59
65
 
60
66
  File.open('nanoc.yaml', 'w') do |io|
67
+ io.write "string_pattern_type: legacy\n"
61
68
  io.write "prune:\n"
62
69
  io.write " auto_prune: true\n"
63
70
  end
@@ -92,6 +99,12 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
92
99
 
93
100
  Dir.mkdir('output/excluded_dir')
94
101
 
102
+ File.open('nanoc.yaml', 'w') do |io|
103
+ io.write "string_pattern_type: legacy\n"
104
+ io.write "prune:\n"
105
+ io.write " auto_prune: false\n"
106
+ end
107
+
95
108
  File.open('output/stray.html', 'w') do |io|
96
109
  io.write 'I am a stray file and I am about to be deleted!'
97
110
  end
@@ -101,6 +114,7 @@ class Nanoc::CLI::Commands::CompileTest < Nanoc::TestCase
101
114
  assert File.file?('output/stray.html')
102
115
 
103
116
  File.open('nanoc.yaml', 'w') do |io|
117
+ io.write "string_pattern_type: legacy\n"
104
118
  io.write "prune:\n"
105
119
  io.write " auto_prune: true\n"
106
120
  io.write " exclude: [ 'excluded_dir' ]\n"
@@ -39,6 +39,30 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
39
39
  end
40
40
  end
41
41
 
42
+ def test_can_compile_site_in_nonempty_directory
43
+ FileUtils.mkdir('foo')
44
+ FileUtils.touch(File.join('foo', 'SomeFile.txt'))
45
+ Nanoc::CLI.run %w( create_site foo --force )
46
+
47
+ FileUtils.cd('foo') do
48
+ site = Nanoc::Int::Site.new('.')
49
+ site.compile
50
+ end
51
+ end
52
+
53
+ def test_compiled_site_output
54
+ FileUtils.mkdir('foo')
55
+ FileUtils.touch(File.join('foo', 'SomeFile.txt'))
56
+ Nanoc::CLI.run %w( create_site foo --force )
57
+
58
+ FileUtils.cd('foo') do
59
+ site = Nanoc::Int::Site.new('.')
60
+ site.compile
61
+
62
+ assert File.file?('output/index.html')
63
+ end
64
+ end
65
+
42
66
  def test_default_encoding
43
67
  unless defined?(Encoding)
44
68
  skip 'No Encoding class'
@@ -61,11 +85,11 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
61
85
 
62
86
  # Try with encoding = specific
63
87
  File.open('nanoc.yaml', 'w') do |io|
64
- io.write("pattern_syntax: glob\n")
88
+ io.write("string_pattern_type: glob\n")
65
89
  io.write("data_sources:\n")
66
90
  io.write(" -\n")
67
91
  io.write(" type: filesystem_unified\n")
68
- io.write(" identifier_style: full\n")
92
+ io.write(" identifier_type: full\n")
69
93
  end
70
94
  site = Nanoc::Int::Site.new('.')
71
95
  site.compile
@@ -84,4 +108,18 @@ class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
84
108
  assert_match(/\/stylesheet.css/, File.read('output/index.html'))
85
109
  end
86
110
  end
111
+
112
+ def test_new_site_prunes_by_default
113
+ FileUtils.mkdir('foo')
114
+ FileUtils.touch(File.join('foo', 'SomeFile.txt'))
115
+ Nanoc::CLI.run %w( create_site foo --force )
116
+
117
+ FileUtils.cd('foo') do
118
+ File.write('output/blah.txt', 'stuff')
119
+
120
+ Nanoc::CLI.run %w( compile )
121
+
122
+ refute File.file?('output/blah.txt')
123
+ end
124
+ end
87
125
  end
@@ -4,7 +4,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
4
4
  def test_run_without_yes
5
5
  with_site do |_site|
6
6
  # Set output dir
7
- File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' }
7
+ File.open('nanoc.yaml', 'w') { |io| io.write "output_dir: output2\nstring_pattern_type: legacy\n" }
8
8
  FileUtils.mkdir_p('output2')
9
9
 
10
10
  # Create source files
@@ -26,7 +26,14 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
26
26
  def test_run_with_yes
27
27
  with_site do |_site|
28
28
  # Set output dir
29
- File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' }
29
+ File.open('nanoc.yaml', 'w') do |io|
30
+ io << 'output_dir: output2' << "\n"
31
+ io << 'string_pattern_type: legacy' << "\n"
32
+ io << 'data_sources:' << "\n"
33
+ io << ' -' << "\n"
34
+ io << ' type: filesystem_unified' << "\n"
35
+ io << ' identifier_type: legacy' << "\n"
36
+ end
30
37
  FileUtils.mkdir_p('output2')
31
38
 
32
39
  # Create source files
@@ -46,7 +53,7 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
46
53
  def test_run_with_dry_run
47
54
  with_site do |_site|
48
55
  # Set output dir
49
- File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output2' }
56
+ File.open('nanoc.yaml', 'w') { |io| io.write "string_pattern_type: legacy\noutput_dir: output2" }
50
57
  FileUtils.mkdir_p('output2')
51
58
 
52
59
  # Create source files
@@ -66,7 +73,15 @@ class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
66
73
  def test_run_with_exclude
67
74
  with_site do |_site|
68
75
  # Set output dir
69
- File.open('nanoc.yaml', 'w') { |io| io.write "prune:\n exclude: [ 'good-dir', 'good-file.html' ]" }
76
+ File.open('nanoc.yaml', 'w') do |io|
77
+ io << 'prune:' << "\n"
78
+ io << ' exclude: [ "good-dir", "good-file.html" ]' << "\n"
79
+ io << 'string_pattern_type: legacy' << "\n"
80
+ io << 'data_sources:' << "\n"
81
+ io << ' -' << "\n"
82
+ io << ' type: filesystem_unified' << "\n"
83
+ io << ' identifier_type: legacy' << "\n"
84
+ end
70
85
  FileUtils.mkdir_p('output')
71
86
 
72
87
  # Create source files
@@ -98,7 +98,7 @@ class Nanoc::DataSources::FilesystemTest < Nanoc::TestCase
98
98
 
99
99
  def test_all_split_files_in_with_same_extensions
100
100
  # Create data source
101
- config = { identifier_style: 'full' }
101
+ config = { identifier_type: 'full' }
102
102
  data_source = Nanoc::DataSources::FilesystemUnified.new(nil, nil, nil, config)
103
103
 
104
104
  # Write sample files
@@ -75,7 +75,7 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
75
75
 
76
76
  def test_load_objects_with_same_extensions
77
77
  # Create data source
78
- data_source = new_data_source({ identifier_style: 'full' })
78
+ data_source = new_data_source({ identifier_type: 'full' })
79
79
 
80
80
  # Create a fake class
81
81
  klass = Class.new do
@@ -133,14 +133,14 @@ class Nanoc::DataSources::FilesystemUnifiedTest < Nanoc::TestCase
133
133
 
134
134
  def test_identifier_for_filename_with_full_style_identifier
135
135
  # Create data source
136
- data_source = new_data_source({ identifier_style: 'full' })
136
+ data_source = new_data_source({ identifier_type: 'full' })
137
137
 
138
138
  # Get input and expected output
139
139
  expected = {
140
- '/foo' => Nanoc::Identifier.new('/foo', style: :full),
141
- '/foo.html' => Nanoc::Identifier.new('/foo.html', style: :full),
142
- '/foo/index.html' => Nanoc::Identifier.new('/foo/index.html', style: :full),
143
- '/foo.html.erb' => Nanoc::Identifier.new('/foo.html.erb', style: :full),
140
+ '/foo' => Nanoc::Identifier.new('/foo', type: :full),
141
+ '/foo.html' => Nanoc::Identifier.new('/foo.html', type: :full),
142
+ '/foo/index.html' => Nanoc::Identifier.new('/foo/index.html', type: :full),
143
+ '/foo.html.erb' => Nanoc::Identifier.new('/foo.html.erb', type: :full),
144
144
  }
145
145
 
146
146
  # Check
@@ -47,7 +47,7 @@ class Nanoc::Extra::Checking::Checks::StaleTest < Nanoc::TestCase
47
47
  assert Dir['content/*'].empty?
48
48
  assert Dir['output/*'].empty?
49
49
 
50
- File.open('nanoc.yaml', 'w') { |io| io.write "prune:\n exclude: [ 'excluded.html' ]" }
50
+ File.open('nanoc.yaml', 'w') { |io| io.write "string_pattern_type: legacy\nprune:\n exclude: [ 'excluded.html' ]" }
51
51
  File.open('content/index.html', 'w') { |io| io.write('stuff') }
52
52
  File.open('output/excluded.html', 'w') { |io| io.write('stuff') }
53
53
  assert calc_issues.empty?
@@ -59,7 +59,7 @@ class Nanoc::Extra::Checking::Checks::StaleTest < Nanoc::TestCase
59
59
  assert Dir['content/*'].empty?
60
60
  assert Dir['output/*'].empty?
61
61
 
62
- File.open('nanoc.yaml', 'w') { |io| io.write "prune:\n blah: meh" }
62
+ File.open('nanoc.yaml', 'w') { |io| io.write "string_pattern_type: legacy\nprune:\n blah: meh" }
63
63
  File.open('content/index.html', 'w') { |io| io.write('stuff') }
64
64
  File.open('output/excluded.html', 'w') { |io| io.write('stuff') }
65
65
  refute calc_issues.empty?
@@ -103,7 +103,14 @@ EOS
103
103
  end
104
104
  end
105
105
 
106
- File.open('nanoc.yaml', 'w') { |io| io.write('stuff: 12345') }
106
+ File.open('nanoc.yaml', 'w') do |io|
107
+ io << 'string_pattern_type: legacy' << "\n"
108
+ io << 'data_sources:' << "\n"
109
+ io << ' -' << "\n"
110
+ io << ' type: filesystem_unified' << "\n"
111
+ io << ' identifier_type: legacy' << "\n"
112
+ end
113
+
107
114
  File.open('Rules', 'w') { |io| io.write(rules_content) }
108
115
  end
109
116
  end
@@ -26,64 +26,6 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
26
26
  item
27
27
  end
28
28
 
29
- def test_articles
30
- # Create items
31
- @items = [
32
- Nanoc::Int::Item.new(
33
- 'blah',
34
- { kind: 'item' },
35
- '/0/'
36
- ),
37
- Nanoc::Int::Item.new(
38
- 'blah blah',
39
- { kind: 'article' },
40
- '/1/'
41
- ),
42
- Nanoc::Int::Item.new(
43
- 'blah blah blah',
44
- { kind: 'article' },
45
- '/2/'
46
- )
47
- ]
48
-
49
- # Check
50
- assert_equal(2, articles.size)
51
- assert articles.include?(@items[1])
52
- assert articles.include?(@items[2])
53
- ensure
54
- # Cleanup
55
- @items = nil
56
- end
57
-
58
- def test_sorted_articles
59
- # Create items
60
- @items = [
61
- Nanoc::Int::Item.new(
62
- 'blah',
63
- { kind: 'item' },
64
- '/0/'
65
- ),
66
- Nanoc::Int::Item.new(
67
- 'blah',
68
- { kind: 'article', created_at: (Date.today - 1).to_s },
69
- '/1/'
70
- ),
71
- Nanoc::Int::Item.new(
72
- 'blah',
73
- { kind: 'article', created_at: (Time.now - 500).to_s },
74
- '/2/'
75
- )
76
- ]
77
-
78
- # Check
79
- assert_equal(2, sorted_articles.size)
80
- assert_equal(@items[2], sorted_articles[0])
81
- assert_equal(@items[1], sorted_articles[1])
82
- ensure
83
- # Cleanup
84
- @items = nil
85
- end
86
-
87
29
  def test_atom_feed
88
30
  if_have 'builder' do
89
31
  # Create items
@@ -623,181 +565,4 @@ class Nanoc::Helpers::BloggingTest < Nanoc::TestCase
623
565
  atom_feed
624
566
  end
625
567
  end
626
-
627
- def test_url_for_without_custom_path_in_feed
628
- # Create site
629
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
630
-
631
- # Create article
632
- item = Nanoc::Int::Item.new('content', {}, '/foo/')
633
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
634
- item.reps[0].paths[:last] = '/foo/bar/'
635
-
636
- # Check
637
- assert_equal('http://example.com/foo/bar/', url_for(item))
638
- ensure
639
- # Cleanup
640
- @item = nil
641
- end
642
-
643
- def test_url_for_with_custom_path_in_feed
644
- # Create site
645
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
646
-
647
- # Create article
648
- item = Nanoc::Int::Item.new(
649
- 'content', { custom_path_in_feed: '/meow/woof/' }, '/foo/')
650
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
651
-
652
- # Check
653
- assert_equal('http://example.com/meow/woof/', url_for(item))
654
- ensure
655
- # Cleanup
656
- @item = nil
657
- end
658
-
659
- def test_url_for_with_custom_url_in_feed
660
- # Create site
661
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
662
-
663
- # Create article
664
- item = Nanoc::Int::Item.new(
665
- 'content', { custom_url_in_feed: 'http://example.org/x' }, '/foo/')
666
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
667
-
668
- # Check
669
- assert_equal('http://example.org/x', url_for(item))
670
- ensure
671
- # Cleanup
672
- @item = nil
673
- end
674
-
675
- def test_url_for_without_base_url
676
- # Create site
677
- @config = Nanoc::ConfigView.new({})
678
-
679
- # Check
680
- assert_raises(Nanoc::Int::Errors::GenericTrivial) do
681
- url_for(nil)
682
- end
683
- end
684
-
685
- def test_url_for_without_path
686
- # Create site
687
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
688
-
689
- # Create article
690
- item = Nanoc::Int::Item.new('content', {}, '/foo/')
691
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
692
- item.reps[0].paths[:last] = nil
693
-
694
- # Check
695
- assert_equal(nil, url_for(item))
696
- end
697
-
698
- def test_feed_url_without_custom_feed_url
699
- # Create site
700
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
701
-
702
- # Create article
703
- @item = Nanoc::Int::Item.new('content', {}, '/foo/')
704
- @item.reps << Nanoc::Int::ItemRep.new(@item, :default)
705
- @item.reps[0].paths[:last] = '/foo/bar/'
706
-
707
- # Check
708
- assert_equal('http://example.com/foo/bar/', feed_url)
709
- ensure
710
- # Cleanup
711
- @item = nil
712
- end
713
-
714
- def test_feed_url_with_custom_feed_url
715
- # Create site
716
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
717
-
718
- # Create feed item
719
- @item = Nanoc::Int::Item.new('content', { feed_url: 'http://example.com/feed/' }, '/foo/')
720
- @item.reps << Nanoc::Int::ItemRep.new(@item, :default)
721
- @item.reps[0].paths[:last] = '/foo/bar/'
722
-
723
- # Check
724
- assert_equal('http://example.com/feed/', feed_url)
725
- ensure
726
- # Cleanup
727
- @item = nil
728
- end
729
-
730
- def test_feed_url_without_base_url
731
- # Create site
732
- @config = Nanoc::ConfigView.new({})
733
-
734
- # Check
735
- assert_raises(Nanoc::Int::Errors::GenericTrivial) do
736
- feed_url
737
- end
738
- end
739
-
740
- def test_atom_tag_for_with_path
741
- # Create site
742
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
743
-
744
- # Create article
745
- item = Nanoc::Int::Item.new('content', { created_at: '2008-05-19' }, '/foo/')
746
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
747
- item.reps[0].paths[:last] = '/foo/bar/'
748
-
749
- # Check
750
- assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
751
- end
752
-
753
- def test_atom_tag_for_without_path
754
- # Create site
755
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
756
-
757
- # Create article
758
- item = Nanoc::Int::Item.new('content', { created_at: '2008-05-19' }, '/baz/qux/')
759
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
760
-
761
- # Check
762
- assert_equal('tag:example.com,2008-05-19:/baz/qux/', atom_tag_for(item))
763
- end
764
-
765
- def test_atom_tag_for_with_base_url_in_dir
766
- # Create site
767
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com/somedir' })
768
-
769
- # Create article
770
- item = Nanoc::Int::Item.new('content', { created_at: '2008-05-19' }, '/foo/')
771
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
772
- item.reps[0].paths[:last] = '/foo/bar/'
773
-
774
- # Check
775
- assert_equal('tag:example.com,2008-05-19:/somedir/foo/bar/', atom_tag_for(item))
776
- end
777
-
778
- def test_atom_tag_for_with_time
779
- # Create site
780
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
781
-
782
- # Create article
783
- item = Nanoc::Int::Item.new('content', { created_at: Time.parse('2008-05-19') }, '/foo/')
784
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
785
- item.reps[0].paths[:last] = '/foo/bar/'
786
-
787
- # Check
788
- assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
789
- end
790
-
791
- def test_atom_tag_for_with_date
792
- # Create site
793
- @config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
794
-
795
- # Create article
796
- item = Nanoc::Int::Item.new('content', { created_at: Date.parse('2008-05-19') }, '/foo/')
797
- item.reps << Nanoc::Int::ItemRep.new(item, :default)
798
- item.reps[0].paths[:last] = '/foo/bar/'
799
-
800
- # Check
801
- assert_equal('tag:example.com,2008-05-19:/foo/bar/', atom_tag_for(item))
802
- end
803
568
  end