/
mutable_layout_collection_view_spec.rb
49 lines (38 loc) · 1.25 KB
/
mutable_layout_collection_view_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
describe Nanoc::MutableLayoutCollectionView do
let(:view_class) { Nanoc::MutableLayoutView }
it_behaves_like 'an identifiable collection'
it_behaves_like 'a mutable identifiable collection'
let(:config) do
{ string_pattern_type: 'glob' }
end
describe '#create' do
let(:layout) do
Nanoc::Int::Layout.new('content', {}, '/asdf/')
end
let(:wrapped) do
Nanoc::Int::IdentifiableCollection.new(config).tap do |coll|
coll << layout
end
end
let(:view) { described_class.new(wrapped, nil) }
it 'creates an object' do
view.create('new content', { title: 'New Page' }, '/new/')
expect(wrapped.size).to eq(2)
expect(wrapped['/new/'].content.string).to eq('new content')
end
it 'returns self' do
ret = view.create('new content', { title: 'New Page' }, '/new/')
expect(ret).to equal(view)
end
end
describe '#inspect' do
let(:wrapped) do
Nanoc::Int::IdentifiableCollection.new(config)
end
let(:view) { described_class.new(wrapped, view_context) }
let(:view_context) { double(:view_context) }
let(:config) { { string_pattern_type: 'glob' } }
subject { view.inspect }
it { is_expected.to eql('<Nanoc::MutableLayoutCollectionView>') }
end
end