Sha256: 1d19ea658b2151c5b5e1ab6aa104a7888260dbdb518e2394e20780985a597f5e

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

describe Nanoc::MutableItemCollectionView do
  let(:view_class) { Nanoc::MutableItemView }
  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(:item) do
      Nanoc::Int::Layout.new('content', {}, '/asdf/')
    end

    let(:wrapped) do
      Nanoc::Int::IdentifiableCollection.new(config).tap do |coll|
        coll << item
      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::MutableItemCollectionView>') }
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
nanoc-4.6.1 spec/nanoc/base/views/mutable_item_collection_view_spec.rb
nanoc-4.6.0 spec/nanoc/base/views/mutable_item_collection_view_spec.rb
nanoc-4.5.4 spec/nanoc/base/views/mutable_item_collection_view_spec.rb
nanoc-4.5.3 spec/nanoc/base/views/mutable_item_collection_view_spec.rb
nanoc-4.5.2 spec/nanoc/base/views/mutable_item_collection_view_spec.rb
nanoc-4.5.1 spec/nanoc/base/views/mutable_item_collection_view_spec.rb
nanoc-4.5.0 spec/nanoc/base/views/mutable_item_collection_view_spec.rb
nanoc-4.4.7 spec/nanoc/base/views/mutable_item_collection_view_spec.rb
nanoc-4.4.6 spec/nanoc/base/views/mutable_item_collection_view_spec.rb