spec/nanoc/base/views/item_view_spec.rb in nanoc-4.8.2 vs spec/nanoc/base/views/item_view_spec.rb in nanoc-4.8.3
- old
+ new
@@ -51,29 +51,33 @@
end
subject { view.parent }
context 'with parent' do
- let(:parent_item) do
- Nanoc::Int::Item.new('parent', {}, '/parent/')
- end
-
context 'full identifier' do
let(:identifier) do
Nanoc::Identifier.new('/parent/me.md')
end
+ let(:parent_item) do
+ Nanoc::Int::Item.new('parent', {}, '/parent.md')
+ end
+
it 'raises' do
expect { subject }.to raise_error(Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem)
end
end
context 'legacy identifier' do
let(:identifier) do
Nanoc::Identifier.new('/parent/me/', type: :legacy)
end
+ 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.unwrap).to eql(parent_item)
end
@@ -89,12 +93,13 @@
context 'non-frozen parent' do
it { is_expected.not_to be_frozen }
end
context 'with root parent' do
- let(:parent_item) { Nanoc::Int::Item.new('parent', {}, '/') }
+ 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.unwrap).to eql(parent_item)
end
@@ -131,14 +136,10 @@
describe '#children' do
let(:item) do
Nanoc::Int::Item.new('me', {}, identifier)
end
- let(:children) do
- [Nanoc::Int::Item.new('child', {}, '/me/child/')]
- end
-
let(:view) { described_class.new(item, view_context) }
let(:items) do
Nanoc::Int::ItemCollection.new(
{},
@@ -154,20 +155,28 @@
context 'full identifier' do
let(:identifier) do
Nanoc::Identifier.new('/me.md')
end
+ let(:children) do
+ [Nanoc::Int::Item.new('child', {}, '/me/child.md')]
+ end
+
it 'raises' do
expect { subject }.to raise_error(Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem)
end
end
context 'legacy identifier' do
let(:identifier) do
Nanoc::Identifier.new('/me/', type: :legacy)
end
+ let(:children) do
+ [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].unwrap).to eql(children[0])
end
@@ -206,11 +215,11 @@
subject { view.compiled_content(params) }
let(:view) { described_class.new(item, view_context) }
let(:item) do
- Nanoc::Int::Item.new('content', {}, '/asdf/')
+ Nanoc::Int::Item.new('content', {}, '/asdf')
end
let(:reps) do
Nanoc::Int::ItemRepRepo.new.tap do |reps|
reps << rep
@@ -353,13 +362,13 @@
describe '#raw_filename' do
# TODO: implement
end
describe '#inspect' do
- let(:item) { Nanoc::Int::Item.new('content', {}, '/asdf/') }
+ 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::ItemWithRepsView identifier=/asdf>') }
end
end