Sha256: 1d2eceb401ae12a5d630689e4712321a9f155c5334985bb889f0eb1737a967fd

Contents?: true

Size: 1.41 KB

Versions: 13

Compression:

Stored size: 1.41 KB

Contents

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, [layout])
    end

    let(:view) { described_class.new(wrapped, nil) }

    it 'creates an object' do
      view.create('new content', { title: 'New Page' }, '/new/')

      expect(view.unwrap.size).to eq(2)
      expect(view.unwrap['/new/'].content.string).to eq('new content')
    end

    it 'does not update wrapped' do
      view.create('new content', { title: 'New Page' }, '/new/')

      expect(wrapped.size).to eq(1)
      expect(wrapped['/new']).to be_nil
    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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
nanoc-4.7.9 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.8 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.7 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.6 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.5 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.4 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.3 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.2 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.1 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.7.0 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.6.4 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.6.3 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb
nanoc-4.6.2 spec/nanoc/base/views/mutable_layout_collection_view_spec.rb