nanoc 4.6.1 → 4.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +1 -1
  3. data/Gemfile.lock +22 -22
  4. data/NEWS.md +12 -0
  5. data/lib/nanoc/base/entities/document.rb +7 -0
  6. data/lib/nanoc/base/entities/identifiable_collection.rb +12 -9
  7. data/lib/nanoc/base/entities/item_rep.rb +24 -28
  8. data/lib/nanoc/base/entities/processing_actions/snapshot.rb +15 -11
  9. data/lib/nanoc/base/entities/rule_memory.rb +15 -5
  10. data/lib/nanoc/base/entities/site.rb +15 -10
  11. data/lib/nanoc/base/entities/snapshot_def.rb +8 -2
  12. data/lib/nanoc/base/repos.rb +3 -0
  13. data/lib/nanoc/base/repos/aggregate_data_source.rb +20 -0
  14. data/lib/nanoc/base/repos/in_mem_data_source.rb +13 -0
  15. data/lib/nanoc/base/repos/prefixed_data_source.rb +19 -0
  16. data/lib/nanoc/base/repos/site_loader.rb +8 -16
  17. data/lib/nanoc/base/repos/snapshot_repo.rb +10 -5
  18. data/lib/nanoc/base/services/action_provider.rb +12 -0
  19. data/lib/nanoc/base/services/compiler/phases/recalculate.rb +5 -2
  20. data/lib/nanoc/base/services/compiler/phases/write.rb +1 -3
  21. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +6 -3
  22. data/lib/nanoc/base/services/executor.rb +2 -4
  23. data/lib/nanoc/base/services/filter.rb +7 -12
  24. data/lib/nanoc/base/services/item_rep_router.rb +40 -16
  25. data/lib/nanoc/base/services/item_rep_writer.rb +19 -3
  26. data/lib/nanoc/base/services/pruner.rb +1 -1
  27. data/lib/nanoc/base/views/item_rep_view.rb +12 -3
  28. data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +1 -1
  29. data/lib/nanoc/base/views/mutable_item_collection_view.rb +1 -1
  30. data/lib/nanoc/base/views/mutable_layout_collection_view.rb +1 -1
  31. data/lib/nanoc/checking/checks/html.rb +1 -1
  32. data/lib/nanoc/checking/checks/stale.rb +2 -1
  33. data/lib/nanoc/checking/checks/w3c_validator.rb +1 -0
  34. data/lib/nanoc/cli/commands/compile.rb +3 -2
  35. data/lib/nanoc/cli/commands/show-data.rb +4 -2
  36. data/lib/nanoc/data_sources/filesystem.rb +1 -1
  37. data/lib/nanoc/helpers/filtering.rb +1 -2
  38. data/lib/nanoc/helpers/rendering.rb +1 -2
  39. data/lib/nanoc/helpers/xml_sitemap.rb +2 -2
  40. data/lib/nanoc/rule_dsl/action_provider.rb +7 -0
  41. data/lib/nanoc/rule_dsl/rule_context.rb +4 -1
  42. data/lib/nanoc/rule_dsl/rule_memory_calculator.rb +33 -13
  43. data/lib/nanoc/spec.rb +5 -6
  44. data/lib/nanoc/version.rb +1 -1
  45. data/spec/nanoc/base/checksummer_spec.rb +19 -9
  46. data/spec/nanoc/base/compiler_spec.rb +4 -8
  47. data/spec/nanoc/base/entities/document_spec.rb +20 -0
  48. data/spec/nanoc/base/entities/identifiable_collection_spec.rb +12 -0
  49. data/spec/nanoc/base/entities/item_rep_spec.rb +1 -1
  50. data/spec/nanoc/base/entities/processing_actions/snapshot_spec.rb +19 -13
  51. data/spec/nanoc/base/entities/rule_memory_spec.rb +39 -3
  52. data/spec/nanoc/base/entities/site_spec.rb +15 -10
  53. data/spec/nanoc/base/filter_spec.rb +28 -1
  54. data/spec/nanoc/base/item_rep_writer_spec.rb +4 -2
  55. data/spec/nanoc/base/repos/outdatedness_store_spec.rb +1 -2
  56. data/spec/nanoc/base/repos/snapshot_repo_spec.rb +4 -4
  57. data/spec/nanoc/base/repos/store_spec.rb +5 -1
  58. data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +9 -10
  59. data/spec/nanoc/base/services/executor_spec.rb +2 -2
  60. data/spec/nanoc/base/services/item_rep_router_spec.rb +83 -39
  61. data/spec/nanoc/base/services/outdatedness_checker_spec.rb +1 -2
  62. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +2 -3
  63. data/spec/nanoc/base/services/pruner_spec.rb +2 -2
  64. data/spec/nanoc/base/views/identifiable_collection_view_spec.rb +46 -28
  65. data/spec/nanoc/base/views/item_rep_view_spec.rb +72 -15
  66. data/spec/nanoc/base/views/item_view_spec.rb +20 -14
  67. data/spec/nanoc/base/views/mutable_identifiable_collection_view_spec.rb +10 -4
  68. data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +10 -5
  69. data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +10 -5
  70. data/spec/nanoc/cli/commands/compile/file_action_printer_spec.rb +1 -1
  71. data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +1 -1
  72. data/spec/nanoc/cli/commands/show_data_spec.rb +9 -7
  73. data/spec/nanoc/cli/commands/show_rules_spec.rb +16 -10
  74. data/spec/nanoc/regressions/gh_1037a_spec.rb +29 -0
  75. data/spec/nanoc/regressions/gh_1037b_spec.rb +18 -0
  76. data/spec/nanoc/regressions/gh_1082a_spec.rb +18 -0
  77. data/spec/nanoc/regressions/gh_1082b_spec.rb +20 -0
  78. data/spec/nanoc/regressions/gh_1082c_spec.rb +19 -0
  79. data/spec/nanoc/regressions/gh_1082d_spec.rb +17 -0
  80. data/spec/nanoc/regressions/gh_1093_spec.rb +49 -0
  81. data/spec/nanoc/regressions/gh_1097_spec.rb +21 -0
  82. data/spec/nanoc/regressions/gh_1100_spec.rb +20 -0
  83. data/spec/nanoc/regressions/gh_1102_spec.rb +26 -0
  84. data/spec/nanoc/regressions/gh_776_spec.rb +1 -5
  85. data/spec/nanoc/rule_dsl/recording_executor_spec.rb +14 -14
  86. data/spec/nanoc/rule_dsl/rule_context_spec.rb +22 -13
  87. data/spec/nanoc/rule_dsl/rule_memory_calculator_spec.rb +38 -54
  88. data/spec/spec_helper.rb +1 -1
  89. data/test/base/test_compiler.rb +3 -4
  90. data/test/base/test_item_array.rb +4 -15
  91. data/test/checking/checks/test_html.rb +4 -3
  92. data/test/cli/commands/test_compile.rb +2 -2
  93. data/test/filters/test_relativize_paths.rb +28 -28
  94. data/test/fixtures/vcr_cassettes/html_run_error.yml +25 -76
  95. data/test/helpers/test_xml_sitemap.rb +22 -19
  96. metadata +16 -2
@@ -14,7 +14,7 @@ describe Nanoc::CLI::Commands::Compile::TimingRecorder, stdio: true do
14
14
 
15
15
  let(:rep) do
16
16
  Nanoc::Int::ItemRep.new(item, :default).tap do |rep|
17
- rep.raw_paths = { default: '/hi.html' }
17
+ rep.raw_paths = { default: ['/hi.html'] }
18
18
  end
19
19
  end
20
20
 
@@ -11,11 +11,14 @@ describe Nanoc::CLI::Commands::ShowData, stdio: true do
11
11
  let(:command) { double(:command) }
12
12
 
13
13
  let(:items) do
14
- Nanoc::Int::IdentifiableCollection.new(config).tap do |ic|
15
- ic << item_about
16
- ic << item_dog
17
- ic << item_other
18
- end
14
+ Nanoc::Int::IdentifiableCollection.new(
15
+ config,
16
+ [
17
+ item_about,
18
+ item_dog,
19
+ item_other,
20
+ ],
21
+ )
19
22
  end
20
23
 
21
24
  let(:item_about) { Nanoc::Int::Item.new('About Me', {}, '/about.md') }
@@ -33,8 +36,7 @@ describe Nanoc::CLI::Commands::ShowData, stdio: true do
33
36
  end
34
37
 
35
38
  let(:layouts) do
36
- Nanoc::Int::IdentifiableCollection.new(config).tap do |ic|
37
- end
39
+ Nanoc::Int::IdentifiableCollection.new(config)
38
40
  end
39
41
 
40
42
  it 'prints a legend' do
@@ -24,11 +24,14 @@ describe Nanoc::CLI::Commands::ShowRules, stdio: true do
24
24
  end
25
25
 
26
26
  let(:items) do
27
- Nanoc::Int::IdentifiableCollection.new(config).tap do |ic|
28
- ic << Nanoc::Int::Item.new('About Me', {}, '/about.md')
29
- ic << Nanoc::Int::Item.new('About My Dog', {}, '/dog.md')
30
- ic << Nanoc::Int::Item.new('Raw Data', {}, '/other.dat')
31
- end
27
+ Nanoc::Int::IdentifiableCollection.new(
28
+ config,
29
+ [
30
+ Nanoc::Int::Item.new('About Me', {}, '/about.md'),
31
+ Nanoc::Int::Item.new('About My Dog', {}, '/dog.md'),
32
+ Nanoc::Int::Item.new('Raw Data', {}, '/other.dat'),
33
+ ],
34
+ )
32
35
  end
33
36
 
34
37
  let(:reps) do
@@ -42,11 +45,14 @@ describe Nanoc::CLI::Commands::ShowRules, stdio: true do
42
45
  end
43
46
 
44
47
  let(:layouts) do
45
- Nanoc::Int::IdentifiableCollection.new(config).tap do |ic|
46
- ic << Nanoc::Int::Layout.new('Default', {}, '/default.erb')
47
- ic << Nanoc::Int::Layout.new('Article', {}, '/article.haml')
48
- ic << Nanoc::Int::Layout.new('Other', {}, '/other.xyzzy')
49
- end
48
+ Nanoc::Int::IdentifiableCollection.new(
49
+ config,
50
+ [
51
+ Nanoc::Int::Layout.new('Default', {}, '/default.erb'),
52
+ Nanoc::Int::Layout.new('Article', {}, '/article.haml'),
53
+ Nanoc::Int::Layout.new('Other', {}, '/other.xyzzy'),
54
+ ],
55
+ )
50
56
  end
51
57
 
52
58
  let(:config) { Nanoc::Int::Configuration.new }
@@ -0,0 +1,29 @@
1
+ describe 'GH-1037', site: true, stdio: true do
2
+ before do
3
+ File.write('content/giraffe.md', 'I am a giraffe!')
4
+ File.write('content/donkey.erb', '[<%= @items["/giraffe.*"].compiled_content(snapshot: :last) %>]')
5
+
6
+ File.write('Rules', <<EOS)
7
+ compile '/donkey.erb' do
8
+ filter :erb
9
+ write '/donkey.txt'
10
+ end
11
+
12
+ compile '/giraffe.*' do
13
+ write '/giraffe.txt'
14
+ write '/giraffe.md'
15
+ end
16
+ EOS
17
+ end
18
+
19
+ it 'writes two files' do
20
+ Nanoc::CLI.run(%w(compile))
21
+ expect(File.read('output/giraffe.txt')).to eql('I am a giraffe!')
22
+ expect(File.read('output/giraffe.md')).to eql('I am a giraffe!')
23
+ end
24
+
25
+ it 'has the right :last snapshot' do
26
+ Nanoc::CLI.run(%w(compile))
27
+ expect(File.read('output/donkey.txt')).to eql('[I am a giraffe!]')
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ describe 'GH-1037', site: true, stdio: true do
2
+ before do
3
+ File.write('content/foo.png', 'stuff')
4
+
5
+ File.write('Rules', <<EOS)
6
+ compile '/*.png' do
7
+ write '/foo-s3cr3t.png'
8
+ end
9
+
10
+ passthrough '/*.png'
11
+ EOS
12
+ end
13
+
14
+ it 'writes one file' do
15
+ Nanoc::CLI.run(%w(compile))
16
+ expect(Dir['output/*']).to eql(['output/foo-s3cr3t.png'])
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ describe 'GH-1082', site: true, stdio: true do
2
+ before do
3
+ File.write('content/a.erb', '<%= @items["/b.*"].binary? %>')
4
+ File.write('content/b.erb', 'stuff')
5
+
6
+ File.write('Rules', <<EOS)
7
+ compile '/*' do
8
+ filter :erb
9
+ write item.identifier.without_ext + '.txt'
10
+ end
11
+ EOS
12
+ end
13
+
14
+ it 'requires /b to be compiled first' do
15
+ Nanoc::CLI.run(%w(compile))
16
+ expect(File.read('output/a.txt')).to eql('false')
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ describe 'GH-1082', site: true, stdio: true do
2
+ before do
3
+ File.write('content/a.erb', '<%= @items["/b.*"].binary? %>')
4
+ File.write('content/b.dat', 'stuff')
5
+
6
+ File.write('Rules', <<EOS)
7
+ compile '/a.*' do
8
+ filter :erb
9
+ write item.identifier.without_ext + '.txt'
10
+ end
11
+
12
+ passthrough '/b.*'
13
+ EOS
14
+ end
15
+
16
+ it 'requires /b to be compiled first' do
17
+ Nanoc::CLI.run(%w(compile))
18
+ expect(File.read('output/a.txt')).to eql('true')
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ describe 'GH-1082', site: true, stdio: true do
2
+ before do
3
+ File.write('content/a.erb', '<%= @items["/b.*"].reps[:default].binary? %>')
4
+ File.write('content/b.erb', '<%= @items["/a.*"].reps[:default].binary? %>')
5
+
6
+ File.write('Rules', <<EOS)
7
+ compile '/*' do
8
+ filter :erb
9
+ write item.identifier.without_ext + '.txt'
10
+ end
11
+ EOS
12
+ end
13
+
14
+ it 'does not require any items to be compiled' do
15
+ Nanoc::CLI.run(%w(compile))
16
+ expect(File.read('output/a.txt')).to eql('false')
17
+ expect(File.read('output/b.txt')).to eql('false')
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ describe 'GH-1082', site: true, stdio: true do
2
+ before do
3
+ File.write('content/a.erb', '<%= @item.reps[:default].binary? %>')
4
+
5
+ File.write('Rules', <<EOS)
6
+ compile '/*' do
7
+ filter :erb
8
+ write item.identifier.without_ext + '.txt'
9
+ end
10
+ EOS
11
+ end
12
+
13
+ it 'does not require any items to be compiled' do
14
+ Nanoc::CLI.run(%w(compile))
15
+ expect(File.read('output/a.txt')).to eql('false')
16
+ end
17
+ end
@@ -0,0 +1,49 @@
1
+ describe 'GH-1093', site: true, stdio: true do
2
+ before do
3
+ File.write('content/index.html', '<%= @items["/z.dat"].reps.all? { |r| File.file?(r.raw_path) } %>')
4
+ File.write('content/z.dat', 'asdf')
5
+
6
+ File.write('Rules', <<EOS)
7
+ class TestFilter < Nanoc::Filter
8
+ identifier :gh_1093_test
9
+
10
+ def run(content, params = {})
11
+ depend_on(deps)
12
+ content
13
+ end
14
+
15
+ private
16
+
17
+ def deps
18
+ assigns[:items].find_all('/**/*.dat')
19
+ end
20
+ end
21
+
22
+ compile '/**/*.html' do
23
+ filter :gh_1093_test
24
+ filter :erb
25
+ write item.identifier.to_s
26
+ end
27
+
28
+ compile '/**/*.dat' do
29
+ write @item.identifier.to_s
30
+ end
31
+
32
+ compile '/**/*.dat', rep: :foo do
33
+ write @item.identifier.to_s + '.foo'
34
+ end
35
+
36
+ compile '/index.html' do
37
+ filter :erb
38
+ write item.identifier.without_ext + '.txt'
39
+ end
40
+
41
+ passthrough '/*.dat'
42
+ EOS
43
+ end
44
+
45
+ it 'generates dependency on all reps' do
46
+ Nanoc::CLI.run(%w(compile))
47
+ expect(File.read('output/index.html')).to eql('true')
48
+ end
49
+ end
@@ -0,0 +1,21 @@
1
+ describe 'GH-1097', site: true, stdio: true do
2
+ before do
3
+ File.write('content/a.dat', 'foo')
4
+ File.write('content/index.html', '<%= @items.find_all("/*.dat").flat_map(&:reps).all? { |r| File.file?(r.raw_path) } %>')
5
+ File.write('content/z.dat', 'quux')
6
+
7
+ File.write('Rules', <<EOS)
8
+ compile '/**/*.html' do
9
+ filter :erb
10
+ write item.identifier.to_s
11
+ end
12
+
13
+ passthrough '/**/*.dat'
14
+ EOS
15
+ end
16
+
17
+ it 'generates dependency on all reps' do
18
+ Nanoc::CLI.run(%w(compile))
19
+ expect(File.read('output/index.html')).to eql('true')
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ describe 'GH-1100', site: true, stdio: true do
2
+ before do
3
+ File.write('content/index.html', '<% @items["stuff"] %>')
4
+
5
+ File.write('Rules', <<EOS)
6
+ preprocess do
7
+ @items.delete_if { |i| false }
8
+ end
9
+
10
+ compile '/**/*.html' do
11
+ filter :erb
12
+ write item.identifier.to_s
13
+ end
14
+ EOS
15
+ end
16
+
17
+ it 'should not crash' do
18
+ Nanoc::CLI.run(%w(compile))
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ describe 'GH-1102', site: true, stdio: true do
2
+ before do
3
+ File.write('content/index.html', '<%= "things" %>')
4
+
5
+ File.write('Rules', <<EOS)
6
+ compile '/**/*.html' do
7
+ filter :erb
8
+ write item.identifier.to_s
9
+ end
10
+ EOS
11
+ end
12
+
13
+ before do
14
+ Nanoc::CLI.run(%w(compile))
15
+ end
16
+
17
+ it 'does not output filename more than once' do
18
+ regex = /skip.*index\.html.*skip.*index\.html/m
19
+ expect { Nanoc::CLI.run(%w(compile --verbose)) }.not_to output(regex).to_stdout
20
+ end
21
+
22
+ it 'outputs filename' do
23
+ regex = /skip.*index\.html/
24
+ expect { Nanoc::CLI.run(%w(compile --verbose)) }.to output(regex).to_stdout
25
+ end
26
+ end
@@ -3,13 +3,9 @@ describe 'GH-776', site: true do
3
3
  File.write('content/donkey.md', 'Donkey!')
4
4
 
5
5
  File.write('Rules', <<EOS)
6
- route '/donkey.*', snapshot: :secret do
7
- '/donkey-secret.html'
8
- end
9
-
10
6
  compile '/donkey.*' do
11
7
  filter :erb
12
- snapshot :secret
8
+ snapshot :secret, path: '/donkey-secret.html'
13
9
  write '/donkey.html'
14
10
  end
15
11
 
@@ -31,8 +31,8 @@ describe Nanoc::RuleDSL::RecordingExecutor do
31
31
  expect(rule_memory.size).to eql(2)
32
32
 
33
33
  expect(rule_memory[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
34
- expect(rule_memory[0].snapshot_name).to eql(:pre)
35
- expect(rule_memory[0].path).to be_nil
34
+ expect(rule_memory[0].snapshot_names).to eql([:pre])
35
+ expect(rule_memory[0].paths).to be_empty
36
36
 
37
37
  expect(rule_memory[1]).to be_a(Nanoc::Int::ProcessingActions::Layout)
38
38
  expect(rule_memory[1].layout_identifier).to eql('/default.*')
@@ -45,8 +45,8 @@ describe Nanoc::RuleDSL::RecordingExecutor do
45
45
  expect(rule_memory.size).to eql(2)
46
46
 
47
47
  expect(rule_memory[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
48
- expect(rule_memory[0].snapshot_name).to eql(:pre)
49
- expect(rule_memory[0].path).to be_nil
48
+ expect(rule_memory[0].snapshot_names).to eql([:pre])
49
+ expect(rule_memory[0].paths).to be_empty
50
50
 
51
51
  expect(rule_memory[1]).to be_a(Nanoc::Int::ProcessingActions::Layout)
52
52
  expect(rule_memory[1].layout_identifier).to eql('/default.*')
@@ -77,8 +77,8 @@ describe Nanoc::RuleDSL::RecordingExecutor do
77
77
  subject
78
78
  expect(rule_memory.size).to eql(1)
79
79
  expect(rule_memory[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
80
- expect(rule_memory[0].snapshot_name).to eql(:foo)
81
- expect(rule_memory[0].path).to be_nil
80
+ expect(rule_memory[0].snapshot_names).to eql([:foo])
81
+ expect(rule_memory[0].paths).to be_empty
82
82
  end
83
83
  end
84
84
 
@@ -92,8 +92,8 @@ describe Nanoc::RuleDSL::RecordingExecutor do
92
92
  subject
93
93
  expect(rule_memory.size).to eql(1)
94
94
  expect(rule_memory[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
95
- expect(rule_memory[0].snapshot_name).to eql(:foo)
96
- expect(rule_memory[0].path).to be_nil
95
+ expect(rule_memory[0].snapshot_names).to eql([:foo])
96
+ expect(rule_memory[0].paths).to be_empty
97
97
  end
98
98
  end
99
99
 
@@ -104,8 +104,8 @@ describe Nanoc::RuleDSL::RecordingExecutor do
104
104
  subject
105
105
  expect(rule_memory.size).to eql(1)
106
106
  expect(rule_memory[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
107
- expect(rule_memory[0].snapshot_name).to eql(:foo)
108
- expect(rule_memory[0].path).to eql('/routed-foo.html')
107
+ expect(rule_memory[0].snapshot_names).to eql([:foo])
108
+ expect(rule_memory[0].paths).to eql(['/routed-foo.html'])
109
109
  end
110
110
  end
111
111
 
@@ -116,8 +116,8 @@ describe Nanoc::RuleDSL::RecordingExecutor do
116
116
  subject
117
117
  expect(rule_memory.size).to eql(1)
118
118
  expect(rule_memory[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
119
- expect(rule_memory[0].snapshot_name).to eql(:foo)
120
- expect(rule_memory[0].path).to eql('/routed-foo.html')
119
+ expect(rule_memory[0].snapshot_names).to eql([:foo])
120
+ expect(rule_memory[0].paths).to eql(['/routed-foo.html'])
121
121
  end
122
122
  end
123
123
  end
@@ -134,9 +134,9 @@ describe Nanoc::RuleDSL::RecordingExecutor do
134
134
 
135
135
  expect(rule_memory.size).to eql(2)
136
136
  expect(rule_memory[0]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
137
- expect(rule_memory[0].snapshot_name).to eql(:foo)
137
+ expect(rule_memory[0].snapshot_names).to eql([:foo])
138
138
  expect(rule_memory[1]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
139
- expect(rule_memory[1].snapshot_name).to eql(:bar)
139
+ expect(rule_memory[1].snapshot_names).to eql([:bar])
140
140
  end
141
141
  end
142
142
  end
@@ -56,10 +56,8 @@ describe(Nanoc::RuleDSL::RuleContext) do
56
56
  let(:child_identifier) { Nanoc::Identifier.new('/foo/bar/', type: :legacy) }
57
57
  let(:child) { Nanoc::Int::Item.new('child', {}, child_identifier) }
58
58
 
59
- before do
60
- items << item
61
- items << parent
62
- items << child
59
+ let(:items) do
60
+ Nanoc::Int::IdentifiableCollection.new(config, [item, parent, child])
63
61
  end
64
62
 
65
63
  it 'has a parent' do
@@ -97,10 +95,8 @@ describe(Nanoc::RuleDSL::RuleContext) do
97
95
  let(:child_identifier) { Nanoc::Identifier.new('/foo/bar/', type: :legacy) }
98
96
  let(:child) { Nanoc::Int::Item.new('child', {}, child_identifier) }
99
97
 
100
- before do
101
- items << item
102
- items << parent
103
- items << child
98
+ let(:items) do
99
+ Nanoc::Int::IdentifiableCollection.new(config, [item, parent, child])
104
100
  end
105
101
 
106
102
  it 'is a view without reps access' do
@@ -166,13 +162,26 @@ describe(Nanoc::RuleDSL::RuleContext) do
166
162
  end
167
163
 
168
164
  describe '#write' do
169
- subject { rule_context.write(path) }
165
+ context 'calling once' do
166
+ subject { rule_context.write('/foo.html') }
170
167
 
171
- let(:path) { '/foo.html' }
168
+ it 'makes a request to the executor' do
169
+ expect(executor).to receive(:snapshot).with(:_0, path: '/foo.html')
170
+ subject
171
+ end
172
+ end
172
173
 
173
- it 'makes a request to the executor' do
174
- expect(executor).to receive(:snapshot).with(:last, path: '/foo.html')
175
- subject
174
+ context 'calling twice' do
175
+ subject do
176
+ rule_context.write('/foo.html')
177
+ rule_context.write('/bar.html')
178
+ end
179
+
180
+ it 'makes two requests to the executor with unique snapshot names' do
181
+ expect(executor).to receive(:snapshot).with(:_0, path: '/foo.html')
182
+ expect(executor).to receive(:snapshot).with(:_1, path: '/bar.html')
183
+ subject
184
+ end
176
185
  end
177
186
  end
178
187
  end