spec/nanoc/base/views/item_view_spec.rb in nanoc-4.8.9 vs spec/nanoc/base/views/item_view_spec.rb in nanoc-4.8.10
- old
+ new
@@ -1,24 +1,26 @@
# frozen_string_literal: true
-describe Nanoc::ItemWithRepsView do
+require_relative 'support/document_view_examples'
+
+describe Nanoc::CompilationItemView do
let(:entity_class) { Nanoc::Int::Item }
let(:other_view_class) { Nanoc::LayoutView }
it_behaves_like 'a document view'
let(:view_context) do
- Nanoc::ViewContext.new(
+ Nanoc::ViewContextForCompilation.new(
reps: reps,
items: items,
dependency_tracker: dependency_tracker,
compilation_context: compilation_context,
snapshot_repo: snapshot_repo,
)
end
- let(:reps) { [] }
- let(:items) { [] }
+ let(:reps) { Nanoc::Int::ItemRepRepo.new }
+ let(:items) { Nanoc::Int::ItemCollection.new(config) }
let(:dependency_tracker) { Nanoc::Int::DependencyTracker.new(dependency_store) }
let(:dependency_store) { Nanoc::Int::DependencyStore.new(empty_items, empty_layouts, config) }
let(:compilation_context) { double(:compilation_context) }
let(:snapshot_repo) { Nanoc::Int::SnapshotRepo.new }
@@ -75,11 +77,11 @@
let(:parent_item) do
Nanoc::Int::Item.new('parent', {}, Nanoc::Identifier.new('/parent/', type: :legacy))
end
it 'returns a view for the parent' do
- expect(subject.class).to eql(Nanoc::ItemWithRepsView)
+ expect(subject.class).to eql(Nanoc::CompilationItemView)
expect(subject.unwrap).to eql(parent_item)
end
it 'returns a view with the right context' do
expect(subject._context).to equal(view_context)
@@ -98,11 +100,11 @@
let(:parent_item) { Nanoc::Int::Item.new('parent', {}, parent_identifier) }
let(:identifier) { Nanoc::Identifier.new('/me/', type: :legacy) }
let(:parent_identifier) { Nanoc::Identifier.new('/', type: :legacy) }
it 'returns a view for the parent' do
- expect(subject.class).to eql(Nanoc::ItemWithRepsView)
+ expect(subject.class).to eql(Nanoc::CompilationItemView)
expect(subject.unwrap).to eql(parent_item)
end
end
end
end
@@ -175,11 +177,11 @@
[Nanoc::Int::Item.new('child', {}, Nanoc::Identifier.new('/me/child/', type: :legacy))]
end
it 'returns views for the children' do
expect(subject.size).to eql(1)
- expect(subject[0].class).to eql(Nanoc::ItemWithRepsView)
+ expect(subject[0].class).to eql(Nanoc::CompilationItemView)
expect(subject[0].unwrap).to eql(children[0])
end
it { is_expected.to be_frozen }
end
@@ -201,11 +203,11 @@
subject { view.reps }
it 'returns a proper item rep collection' do
expect(subject.size).to eq(2)
- expect(subject.class).to eql(Nanoc::ItemRepCollectionView)
+ expect(subject.class).to eql(Nanoc::CompilationItemRepCollectionView)
end
it 'returns a view with the right context' do
expect(subject._context).to eq(view_context)
end
@@ -283,11 +285,11 @@
context 'requesting other rep' do
let(:params) { { rep: :other } }
it 'raises an error' do
- expect { subject }.to raise_error(Nanoc::ItemRepCollectionView::NoSuchItemRepError)
+ expect { subject }.to raise_error(Nanoc::BasicItemRepCollectionView::NoSuchItemRepError)
end
end
end
describe '#path' do
@@ -348,11 +350,11 @@
context 'requesting other rep' do
let(:params) { { rep: :other } }
it 'raises an error' do
- expect { subject }.to raise_error(Nanoc::ItemRepCollectionView::NoSuchItemRepError)
+ expect { subject }.to raise_error(Nanoc::BasicItemRepCollectionView::NoSuchItemRepError)
end
end
end
describe '#binary?' do
@@ -367,8 +369,8 @@
let(:item) { Nanoc::Int::Item.new('content', {}, '/asdf') }
let(:view) { described_class.new(item, nil) }
subject { view.inspect }
- it { is_expected.to eql('<Nanoc::ItemWithRepsView identifier=/asdf>') }
+ it { is_expected.to eql('<Nanoc::CompilationItemView identifier=/asdf>') }
end
end