nanoc 4.8.9 → 4.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -4
  3. data/Gemfile +2 -1
  4. data/NEWS.md +7 -0
  5. data/README.md +1 -1
  6. data/lib/nanoc.rb +2 -6
  7. data/lib/nanoc/base/entities/site.rb +9 -5
  8. data/lib/nanoc/base/repos/data_source.rb +0 -15
  9. data/lib/nanoc/base/repos/outdatedness_store.rb +17 -15
  10. data/lib/nanoc/base/services/compilation_context.rb +4 -4
  11. data/lib/nanoc/base/services/compiler.rb +102 -103
  12. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +7 -7
  13. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +4 -2
  14. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +25 -7
  15. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +3 -3
  16. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +3 -0
  17. data/lib/nanoc/base/services/compiler_loader.rb +1 -4
  18. data/lib/nanoc/base/views.rb +13 -6
  19. data/lib/nanoc/base/views/{item_rep_collection_view.rb → basic_item_rep_collection_view.rb} +6 -6
  20. data/lib/nanoc/base/views/{item_rep_view.rb → basic_item_rep_view.rb} +8 -29
  21. data/lib/nanoc/base/views/{item_without_reps_view.rb → basic_item_view.rb} +3 -3
  22. data/lib/nanoc/base/views/compilation_item_rep_collection_view.rb +10 -0
  23. data/lib/nanoc/base/views/compilation_item_rep_view.rb +42 -0
  24. data/lib/nanoc/base/views/{mixins/with_reps_view_mixin.rb → compilation_item_view.rb} +3 -3
  25. data/lib/nanoc/base/views/item_collection_with_reps_view.rb +1 -1
  26. data/lib/nanoc/base/views/item_collection_without_reps_view.rb +1 -1
  27. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +1 -1
  28. data/lib/nanoc/base/views/mutable_item_view.rb +1 -1
  29. data/lib/nanoc/base/views/post_compile_item_rep_collection_view.rb +1 -1
  30. data/lib/nanoc/base/views/post_compile_item_rep_view.rb +7 -2
  31. data/lib/nanoc/base/views/post_compile_item_view.rb +1 -1
  32. data/lib/nanoc/base/views/{view_context.rb → view_context_for_compilation.rb} +10 -1
  33. data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +18 -0
  34. data/lib/nanoc/base/views/view_context_for_shell.rb +23 -0
  35. data/lib/nanoc/checking/check.rb +5 -1
  36. data/lib/nanoc/checking/runner.rb +1 -1
  37. data/lib/nanoc/cli.rb +1 -0
  38. data/lib/nanoc/cli/command_runner.rb +1 -7
  39. data/lib/nanoc/cli/commands/check.rb +2 -2
  40. data/lib/nanoc/cli/commands/compile.rb +8 -47
  41. data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +9 -0
  42. data/lib/nanoc/cli/commands/compile_listeners/aggregate.rb +49 -0
  43. data/lib/nanoc/cli/commands/deploy.rb +2 -1
  44. data/lib/nanoc/cli/commands/prune.rb +5 -4
  45. data/lib/nanoc/cli/commands/shell.rb +4 -6
  46. data/lib/nanoc/cli/commands/show-data.rb +20 -27
  47. data/lib/nanoc/cli/commands/show-rules.rb +20 -22
  48. data/lib/nanoc/cli/error_handler.rb +0 -17
  49. data/lib/nanoc/data_sources/filesystem.rb +4 -2
  50. data/lib/nanoc/deploying/deployers/fog.rb +4 -1
  51. data/lib/nanoc/helpers/link_to.rb +1 -1
  52. data/lib/nanoc/rule_dsl/action_provider.rb +8 -11
  53. data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +14 -5
  54. data/lib/nanoc/rule_dsl/recording_executor.rb +4 -0
  55. data/lib/nanoc/rule_dsl/rule.rb +14 -9
  56. data/lib/nanoc/rule_dsl/rule_context.rb +4 -4
  57. data/lib/nanoc/spec.rb +27 -19
  58. data/lib/nanoc/version.rb +1 -1
  59. data/spec/nanoc/base/checksummer_spec.rb +19 -11
  60. data/spec/nanoc/base/compiler_spec.rb +18 -14
  61. data/spec/nanoc/base/filter_spec.rb +7 -6
  62. data/spec/nanoc/base/repos/outdatedness_store_spec.rb +3 -32
  63. data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +2 -1
  64. data/spec/nanoc/base/services/compiler/stages/determine_outdatedness_spec.rb +148 -0
  65. data/spec/nanoc/base/services/compiler/stages/preprocess_spec.rb +110 -0
  66. data/spec/nanoc/base/services/executor_spec.rb +6 -6
  67. data/spec/nanoc/base/views/basic_item_rep_collection_view_spec.rb +8 -0
  68. data/spec/nanoc/base/views/basic_item_rep_view_spec.rb +9 -0
  69. data/spec/nanoc/base/views/compilation_item_rep_collection_view_spec.rb +8 -0
  70. data/spec/nanoc/base/views/compilation_item_rep_view_spec.rb +136 -0
  71. data/spec/nanoc/base/views/config_view_spec.rb +5 -5
  72. data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +4 -2
  73. data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +4 -2
  74. data/spec/nanoc/base/views/item_view_spec.rb +13 -11
  75. data/spec/nanoc/base/views/layout_collection_view_spec.rb +3 -1
  76. data/spec/nanoc/base/views/layout_view_spec.rb +3 -1
  77. data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +5 -2
  78. data/spec/nanoc/base/views/mutable_item_view_spec.rb +2 -0
  79. data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +5 -2
  80. data/spec/nanoc/base/views/mutable_layout_view_spec.rb +2 -0
  81. data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +2 -0
  82. data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +9 -3
  83. data/spec/nanoc/base/views/{document_view_spec.rb → support/document_view_examples.rb} +5 -5
  84. data/spec/nanoc/base/views/{identifiable_collection_view_spec.rb → support/identifiable_collection_view_examples.rb} +4 -4
  85. data/spec/nanoc/base/views/{item_rep_collection_view_spec.rb → support/item_rep_collection_view_examples.rb} +3 -8
  86. data/spec/nanoc/base/views/{item_rep_view_spec.rb → support/item_rep_view_examples.rb} +10 -111
  87. data/spec/nanoc/base/views/{mutable_document_view_spec.rb → support/mutable_document_view_examples.rb} +7 -6
  88. data/spec/nanoc/base/views/{mutable_identifiable_collection_view_spec.rb → support/mutable_identifiable_collection_view_examples.rb} +1 -1
  89. data/spec/nanoc/cli/commands/compile/abstract_spec.rb +80 -0
  90. data/spec/nanoc/cli/commands/compile_spec.rb +30 -51
  91. data/spec/nanoc/cli/commands/show_data_spec.rb +2 -23
  92. data/spec/nanoc/cli/commands/show_rules_spec.rb +4 -2
  93. data/spec/nanoc/regressions/gh_767_spec.rb +1 -1
  94. data/spec/nanoc/regressions/gh_776_spec.rb +2 -1
  95. data/spec/nanoc/rule_dsl/action_sequence_calculator_spec.rb +25 -12
  96. data/spec/nanoc/rule_dsl/rule_context_spec.rb +16 -6
  97. data/test/base/test_data_source.rb +0 -18
  98. data/test/checking/checks/test_external_links.rb +4 -6
  99. data/test/checking/checks/test_internal_links.rb +6 -9
  100. data/test/cli/commands/test_compile.rb +0 -35
  101. data/test/cli/test_cleaning_stream.rb +1 -1
  102. data/test/data_sources/test_filesystem.rb +16 -0
  103. data/test/filters/test_kramdown.rb +4 -4
  104. data/test/filters/test_sass.rb +1 -1
  105. data/test/filters/test_slim.rb +7 -5
  106. data/test/filters/test_xsl.rb +10 -8
  107. data/test/helpers/test_blogging.rb +5 -5
  108. data/test/helpers/test_capturing.rb +8 -6
  109. data/test/helpers/test_link_to.rb +4 -4
  110. data/test/helpers/test_xml_sitemap.rb +19 -19
  111. metadata +25 -15
  112. data/lib/nanoc/base/views/item_with_reps_view.rb +0 -7
  113. data/spec/nanoc/base/core_ext/pathname_spec.rb +0 -0
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'support/item_rep_collection_view_examples'
4
+
5
+ describe Nanoc::BasicItemRepCollectionView do
6
+ it_behaves_like 'an item rep collection view'
7
+ let(:expected_view_class) { Nanoc::BasicItemRepView }
8
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'support/item_rep_view_examples'
4
+
5
+ describe Nanoc::BasicItemRepView do
6
+ let(:expected_item_view_class) { Nanoc::BasicItemView }
7
+
8
+ it_behaves_like 'an item rep view'
9
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'support/item_rep_collection_view_examples'
4
+
5
+ describe Nanoc::CompilationItemRepCollectionView do
6
+ it_behaves_like 'an item rep collection view'
7
+ let(:expected_view_class) { Nanoc::CompilationItemRepView }
8
+ end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'support/item_rep_view_examples'
4
+
5
+ describe Nanoc::CompilationItemRepView do
6
+ let(:expected_item_view_class) { Nanoc::CompilationItemView }
7
+
8
+ it_behaves_like 'an item rep view'
9
+
10
+ let(:view_context) do
11
+ Nanoc::ViewContextForCompilation.new(
12
+ reps: Nanoc::Int::ItemRepRepo.new,
13
+ items: Nanoc::Int::ItemCollection.new(config),
14
+ dependency_tracker: dependency_tracker,
15
+ compilation_context: compilation_context,
16
+ snapshot_repo: snapshot_repo,
17
+ )
18
+ end
19
+
20
+ let(:compilation_context) { double(:compilation_context) }
21
+ let(:snapshot_repo) { Nanoc::Int::SnapshotRepo.new }
22
+
23
+ let(:dependency_tracker) { Nanoc::Int::DependencyTracker.new(dependency_store) }
24
+ let(:dependency_store) { Nanoc::Int::DependencyStore.new(empty_items, empty_layouts, config) }
25
+ let(:base_item) { Nanoc::Int::Item.new('base', {}, '/base.md') }
26
+
27
+ let(:empty_items) { Nanoc::Int::ItemCollection.new(config) }
28
+ let(:empty_layouts) { Nanoc::Int::LayoutCollection.new(config) }
29
+
30
+ let(:config) { Nanoc::Int::Configuration.new.with_defaults }
31
+
32
+ before do
33
+ dependency_tracker.enter(base_item)
34
+ end
35
+
36
+ describe '#raw_path' do
37
+ subject { Fiber.new { view.raw_path }.resume }
38
+
39
+ let(:view) { described_class.new(rep, view_context) }
40
+
41
+ let(:rep) do
42
+ Nanoc::Int::ItemRep.new(item, :default).tap do |ir|
43
+ ir.raw_paths = {
44
+ last: ['output/about/index.html'],
45
+ }
46
+ end
47
+ end
48
+
49
+ let(:item) do
50
+ Nanoc::Int::Item.new('content', {}, '/asdf.md')
51
+ end
52
+
53
+ context 'rep is not compiled' do
54
+ it 'creates a dependency' do
55
+ expect { subject }.to change { dependency_store.objects_causing_outdatedness_of(base_item) }.from([]).to([item])
56
+ end
57
+
58
+ it 'creates a dependency with the right props' do
59
+ subject
60
+ dep = dependency_store.dependencies_causing_outdatedness_of(base_item)[0]
61
+
62
+ expect(dep.props.compiled_content?).to eq(true)
63
+
64
+ expect(dep.props.raw_content?).to eq(false)
65
+ expect(dep.props.attributes?).to eq(false)
66
+ expect(dep.props.path?).to eq(false)
67
+ end
68
+
69
+ it { should be_a(Nanoc::Int::Errors::UnmetDependency) }
70
+ end
71
+
72
+ context 'rep is compiled' do
73
+ before { rep.compiled = true }
74
+
75
+ it 'creates a dependency' do
76
+ expect { subject }.to change { dependency_store.objects_causing_outdatedness_of(base_item) }.from([]).to([item])
77
+ end
78
+
79
+ it 'creates a dependency with the right props' do
80
+ subject
81
+ dep = dependency_store.dependencies_causing_outdatedness_of(base_item)[0]
82
+
83
+ expect(dep.props.compiled_content?).to eq(true)
84
+
85
+ expect(dep.props.raw_content?).to eq(false)
86
+ expect(dep.props.attributes?).to eq(false)
87
+ expect(dep.props.path?).to eq(false)
88
+ end
89
+
90
+ it { should eq('output/about/index.html') }
91
+ end
92
+ end
93
+
94
+ describe '#compiled_content' do
95
+ subject { view.compiled_content }
96
+
97
+ let(:view) { described_class.new(rep, view_context) }
98
+
99
+ let(:rep) do
100
+ Nanoc::Int::ItemRep.new(item, :default).tap do |ir|
101
+ ir.compiled = true
102
+ ir.snapshot_defs = [
103
+ Nanoc::Int::SnapshotDef.new(:last, binary: false),
104
+ ]
105
+ end
106
+ end
107
+
108
+ let(:item) do
109
+ Nanoc::Int::Item.new('content', {}, '/asdf.md')
110
+ end
111
+
112
+ before do
113
+ snapshot_repo.set(rep, :last, Nanoc::Int::TextualContent.new('Hallo'))
114
+ end
115
+
116
+ it 'creates a dependency' do
117
+ expect { subject }
118
+ .to change { dependency_store.objects_causing_outdatedness_of(base_item) }
119
+ .from([])
120
+ .to([item])
121
+ end
122
+
123
+ it 'creates a dependency with the right props' do
124
+ subject
125
+ dep = dependency_store.dependencies_causing_outdatedness_of(base_item)[0]
126
+
127
+ expect(dep.props.compiled_content?).to eq(true)
128
+
129
+ expect(dep.props.raw_content?).to eq(false)
130
+ expect(dep.props.attributes?).to eq(false)
131
+ expect(dep.props.path?).to eq(false)
132
+ end
133
+
134
+ it { should eq('Hallo') }
135
+ end
136
+ end
@@ -10,12 +10,12 @@ describe Nanoc::ConfigView do
10
10
  let(:view) { described_class.new(config, view_context) }
11
11
 
12
12
  let(:view_context) do
13
- Nanoc::ViewContext.new(
14
- reps: double(:reps),
15
- items: double(:items),
16
- dependency_tracker: dependency_tracker,
13
+ Nanoc::ViewContextForCompilation.new(
14
+ reps: Nanoc::Int::ItemRepRepo.new,
15
+ items: Nanoc::Int::ItemCollection.new(config),
16
+ dependency_tracker: dependency_tracker,
17
17
  compilation_context: double(:compilation_context),
18
- snapshot_repo: double(:snapshot_repo),
18
+ snapshot_repo: double(:snapshot_repo),
19
19
  )
20
20
  end
21
21
 
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/identifiable_collection_view_examples'
4
+
3
5
  describe Nanoc::ItemCollectionWithRepsView do
4
- let(:view_class) { Nanoc::ItemWithRepsView }
6
+ let(:view_class) { Nanoc::CompilationItemView }
5
7
  let(:collection_class) { Nanoc::Int::ItemCollection }
6
- it_behaves_like 'an identifiable collection'
8
+ it_behaves_like 'an identifiable collection view'
7
9
 
8
10
  describe '#inspect' do
9
11
  let(:wrapped) do
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/identifiable_collection_view_examples'
4
+
3
5
  describe Nanoc::ItemCollectionWithoutRepsView do
4
- let(:view_class) { Nanoc::ItemWithoutRepsView }
6
+ let(:view_class) { Nanoc::BasicItemView }
5
7
  let(:collection_class) { Nanoc::Int::ItemCollection }
6
- it_behaves_like 'an identifiable collection'
8
+ it_behaves_like 'an identifiable collection view'
7
9
 
8
10
  describe '#inspect' do
9
11
  let(:wrapped) do
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- describe Nanoc::ItemWithRepsView do
3
+ require_relative 'support/document_view_examples'
4
+
5
+ describe Nanoc::CompilationItemView do
4
6
  let(:entity_class) { Nanoc::Int::Item }
5
7
  let(:other_view_class) { Nanoc::LayoutView }
6
8
  it_behaves_like 'a document view'
7
9
 
8
10
  let(:view_context) do
9
- Nanoc::ViewContext.new(
11
+ Nanoc::ViewContextForCompilation.new(
10
12
  reps: reps,
11
13
  items: items,
12
14
  dependency_tracker: dependency_tracker,
@@ -15,8 +17,8 @@ describe Nanoc::ItemWithRepsView do
15
17
  )
16
18
  end
17
19
 
18
- let(:reps) { [] }
19
- let(:items) { [] }
20
+ let(:reps) { Nanoc::Int::ItemRepRepo.new }
21
+ let(:items) { Nanoc::Int::ItemCollection.new(config) }
20
22
  let(:dependency_tracker) { Nanoc::Int::DependencyTracker.new(dependency_store) }
21
23
  let(:dependency_store) { Nanoc::Int::DependencyStore.new(empty_items, empty_layouts, config) }
22
24
  let(:compilation_context) { double(:compilation_context) }
@@ -77,7 +79,7 @@ describe Nanoc::ItemWithRepsView do
77
79
  end
78
80
 
79
81
  it 'returns a view for the parent' do
80
- expect(subject.class).to eql(Nanoc::ItemWithRepsView)
82
+ expect(subject.class).to eql(Nanoc::CompilationItemView)
81
83
  expect(subject.unwrap).to eql(parent_item)
82
84
  end
83
85
 
@@ -100,7 +102,7 @@ describe Nanoc::ItemWithRepsView do
100
102
  let(:parent_identifier) { Nanoc::Identifier.new('/', type: :legacy) }
101
103
 
102
104
  it 'returns a view for the parent' do
103
- expect(subject.class).to eql(Nanoc::ItemWithRepsView)
105
+ expect(subject.class).to eql(Nanoc::CompilationItemView)
104
106
  expect(subject.unwrap).to eql(parent_item)
105
107
  end
106
108
  end
@@ -177,7 +179,7 @@ describe Nanoc::ItemWithRepsView do
177
179
 
178
180
  it 'returns views for the children' do
179
181
  expect(subject.size).to eql(1)
180
- expect(subject[0].class).to eql(Nanoc::ItemWithRepsView)
182
+ expect(subject[0].class).to eql(Nanoc::CompilationItemView)
181
183
  expect(subject[0].unwrap).to eql(children[0])
182
184
  end
183
185
 
@@ -203,7 +205,7 @@ describe Nanoc::ItemWithRepsView do
203
205
 
204
206
  it 'returns a proper item rep collection' do
205
207
  expect(subject.size).to eq(2)
206
- expect(subject.class).to eql(Nanoc::ItemRepCollectionView)
208
+ expect(subject.class).to eql(Nanoc::CompilationItemRepCollectionView)
207
209
  end
208
210
 
209
211
  it 'returns a view with the right context' do
@@ -285,7 +287,7 @@ describe Nanoc::ItemWithRepsView do
285
287
  let(:params) { { rep: :other } }
286
288
 
287
289
  it 'raises an error' do
288
- expect { subject }.to raise_error(Nanoc::ItemRepCollectionView::NoSuchItemRepError)
290
+ expect { subject }.to raise_error(Nanoc::BasicItemRepCollectionView::NoSuchItemRepError)
289
291
  end
290
292
  end
291
293
  end
@@ -350,7 +352,7 @@ describe Nanoc::ItemWithRepsView do
350
352
  let(:params) { { rep: :other } }
351
353
 
352
354
  it 'raises an error' do
353
- expect { subject }.to raise_error(Nanoc::ItemRepCollectionView::NoSuchItemRepError)
355
+ expect { subject }.to raise_error(Nanoc::BasicItemRepCollectionView::NoSuchItemRepError)
354
356
  end
355
357
  end
356
358
  end
@@ -369,6 +371,6 @@ describe Nanoc::ItemWithRepsView do
369
371
 
370
372
  subject { view.inspect }
371
373
 
372
- it { is_expected.to eql('<Nanoc::ItemWithRepsView identifier=/asdf>') }
374
+ it { is_expected.to eql('<Nanoc::CompilationItemView identifier=/asdf>') }
373
375
  end
374
376
  end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/identifiable_collection_view_examples'
4
+
3
5
  describe Nanoc::LayoutCollectionView do
4
6
  let(:view_class) { Nanoc::LayoutView }
5
7
  let(:collection_class) { Nanoc::Int::LayoutCollection }
6
- it_behaves_like 'an identifiable collection'
8
+ it_behaves_like 'an identifiable collection view'
7
9
 
8
10
  describe '#inspect' do
9
11
  let(:wrapped) do
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/document_view_examples'
4
+
3
5
  describe Nanoc::LayoutView do
4
6
  let(:entity_class) { Nanoc::Int::Layout }
5
- let(:other_view_class) { Nanoc::ItemWithRepsView }
7
+ let(:other_view_class) { Nanoc::CompilationItemView }
6
8
  it_behaves_like 'a document view'
7
9
 
8
10
  describe '#inspect' do
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/identifiable_collection_view_examples'
4
+ require_relative 'support/mutable_identifiable_collection_view_examples'
5
+
3
6
  describe Nanoc::MutableItemCollectionView do
4
7
  let(:view_class) { Nanoc::MutableItemView }
5
8
  let(:collection_class) { Nanoc::Int::ItemCollection }
6
- it_behaves_like 'an identifiable collection'
7
- it_behaves_like 'a mutable identifiable collection'
9
+ it_behaves_like 'an identifiable collection view'
10
+ it_behaves_like 'a mutable identifiable collection view'
8
11
 
9
12
  let(:config) do
10
13
  { string_pattern_type: 'glob' }
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/mutable_document_view_examples'
4
+
3
5
  describe Nanoc::MutableItemView do
4
6
  let(:entity_class) { Nanoc::Int::Item }
5
7
  it_behaves_like 'a mutable document view'
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/identifiable_collection_view_examples'
4
+ require_relative 'support/mutable_identifiable_collection_view_examples'
5
+
3
6
  describe Nanoc::MutableLayoutCollectionView do
4
7
  let(:view_class) { Nanoc::MutableLayoutView }
5
8
  let(:collection_class) { Nanoc::Int::LayoutCollection }
6
- it_behaves_like 'an identifiable collection'
7
- it_behaves_like 'a mutable identifiable collection'
9
+ it_behaves_like 'an identifiable collection view'
10
+ it_behaves_like 'a mutable identifiable collection view'
8
11
 
9
12
  let(:config) do
10
13
  { string_pattern_type: 'glob' }
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/mutable_document_view_examples'
4
+
3
5
  describe Nanoc::MutableLayoutView do
4
6
  let(:entity_class) { Nanoc::Int::Layout }
5
7
  it_behaves_like 'a mutable document view'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/item_rep_collection_view_examples'
4
+
3
5
  describe Nanoc::PostCompileItemRepCollectionView do
4
6
  it_behaves_like 'an item rep collection view'
5
7
  let(:expected_view_class) { Nanoc::PostCompileItemRepView }
@@ -1,14 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'support/item_rep_view_examples'
4
+
3
5
  describe Nanoc::PostCompileItemRepView do
6
+ let(:expected_item_view_class) { Nanoc::PostCompileItemView }
7
+
8
+ it_behaves_like 'an item rep view'
9
+
4
10
  let(:item_rep) { Nanoc::Int::ItemRep.new(item, :jacques) }
5
11
  let(:item) { Nanoc::Int::Item.new('asdf', {}, '/foo') }
6
12
  let(:view) { described_class.new(item_rep, view_context) }
7
13
 
8
14
  let(:view_context) do
9
- Nanoc::ViewContext.new(
10
- reps: reps,
11
- items: items,
15
+ Nanoc::ViewContextForCompilation.new(
16
+ reps: Nanoc::Int::ItemRepRepo.new,
17
+ items: Nanoc::Int::ItemCollection.new(config),
12
18
  dependency_tracker: dependency_tracker,
13
19
  compilation_context: compilation_context,
14
20
  snapshot_repo: snapshot_repo,
@@ -4,12 +4,12 @@ shared_examples 'a document view' do
4
4
  let(:view) { described_class.new(document, view_context) }
5
5
 
6
6
  let(:view_context) do
7
- Nanoc::ViewContext.new(
8
- reps: double(:reps),
9
- items: double(:items),
10
- dependency_tracker: dependency_tracker,
7
+ Nanoc::ViewContextForCompilation.new(
8
+ reps: Nanoc::Int::ItemRepRepo.new,
9
+ items: Nanoc::Int::ItemCollection.new(config),
10
+ dependency_tracker: dependency_tracker,
11
11
  compilation_context: double(:compilation_context),
12
- snapshot_repo: double(:snapshot_repo),
12
+ snapshot_repo: double(:snapshot_repo),
13
13
  )
14
14
  end
15
15
 
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Needs :view_class
4
- shared_examples 'an identifiable collection' do
4
+ shared_examples 'an identifiable collection view' do
5
5
  let(:view) { described_class.new(wrapped, view_context) }
6
6
 
7
7
  let(:view_context) do
8
- Nanoc::ViewContext.new(
9
- reps: double(:__reps),
10
- items: double(:__items),
8
+ Nanoc::ViewContextForCompilation.new(
9
+ reps: Nanoc::Int::ItemRepRepo.new,
10
+ items: Nanoc::Int::ItemCollection.new(config),
11
11
  dependency_tracker: dependency_tracker,
12
12
  compilation_context: double(:__compilation_context),
13
13
  snapshot_repo: double(:__snapshot_repo),