Sha256: 9d4656e4b205cb46206bb04f78c0ef02e888e6079b452cfdf285895f8b63c8a1

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

shared_examples 'a mutable identifiable collection' do
  let(:view) { described_class.new(wrapped, view_context) }

  let(:view_context) { double(:view_context) }

  let(:config) do
    {}
  end

  describe '#delete_if' do
    let(:wrapped) do
      Nanoc::Int::IdentifiableCollection.new(
        config,
        [double(:identifiable, identifier: Nanoc::Identifier.new('/asdf/'))],
      )
    end

    it 'deletes matching' do
      view.delete_if { |i| i.identifier == '/asdf/' }
      expect(view.unwrap).to be_empty
    end

    it 'does not mutate' do
      view.delete_if { |i| i.identifier == '/asdf/' }
      expect(wrapped).not_to be_empty
    end

    it 'deletes no non-matching' do
      view.delete_if { |i| i.identifier == '/blah/' }
      expect(wrapped).not_to be_empty
    end

    it 'returns self' do
      ret = view.delete_if { |_i| false }
      expect(ret).to equal(view)
    end

    it 'yields items with the proper context' do
      view.delete_if { |i| expect(i._context).to equal(view_context) }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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