Sha256: 177c992fc489e989a5d8f26695418d166b7d6a9b432cad598fc5f23368a52326

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

describe Nanoc::PostCompileItemView do
  let(:item) { Nanoc::Int::Item.new('blah', {}, '/foo.md') }
  let(:rep_a) { Nanoc::Int::ItemRep.new(item, :no_mod) }
  let(:rep_b) { Nanoc::Int::ItemRep.new(item, :modded).tap { |r| r.modified = true } }

  let(:reps) do
    Nanoc::Int::ItemRepRepo.new.tap do |reps|
      reps << rep_a
      reps << rep_b
    end
  end

  let(:view_context) { double(:view_context, reps: reps) }
  let(:view) { described_class.new(item, view_context) }

  shared_examples 'a method that returns modified reps only' do
    it 'returns only modified items' do
      expect(subject.size).to eq(1)
      expect(subject.map(&:name)).to eq(%i[modded])
    end

    it 'returns an array' do
      expect(subject.class).to eql(Array)
    end
  end

  shared_examples 'a method that returns PostCompileItemRepViews' do
    it 'returns PostCompileItemRepViews' do
      expect(subject).to all(be_a(Nanoc::PostCompileItemRepView))
    end
  end

  describe '#modified_reps' do
    subject { view.modified_reps }

    it_behaves_like 'a method that returns modified reps only'
    it_behaves_like 'a method that returns PostCompileItemRepViews'
  end

  describe '#modified' do
    subject { view.modified }

    it_behaves_like 'a method that returns modified reps only'
    it_behaves_like 'a method that returns PostCompileItemRepViews'
  end

  describe '#reps' do
    subject { view.reps }

    it_behaves_like 'a method that returns PostCompileItemRepViews'

    it 'returns a PostCompileItemRepCollectionView' do
      expect(subject).to be_a(Nanoc::PostCompileItemRepCollectionView)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
nanoc-4.8.12 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.11 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.10 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.9 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.8 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.7 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.6 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.5 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.4 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.3 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.2 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.1 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.8.0 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.7.14 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.7.13 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.7.12 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.7.11 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.7.10 spec/nanoc/base/views/post_compile_item_view_spec.rb