Sha256: 96076d981fc7f0d7abb844790c3cb394bc6d21894ed3fe59ef10d821bd05800b

Contents?: true

Size: 923 Bytes

Versions: 9

Compression:

Stored size: 923 Bytes

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).tap do |coll|
        coll << double(:identifiable, identifier: Nanoc::Identifier.new('/asdf/'))
      end
    end

    it 'deletes matching' do
      view.delete_if { |i| i.identifier == '/asdf/' }
      expect(wrapped).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

9 entries across 9 versions & 1 rubygems

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