Sha256: 4899ab3c0b1e576908b3700e6d44a0e72af09542f8771666f571b5ff71f14d96

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

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

4 entries across 4 versions & 1 rubygems

Version Path
nanoc-4.7.9 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.7.8 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.7.7 spec/nanoc/base/views/post_compile_item_view_spec.rb
nanoc-4.7.6 spec/nanoc/base/views/post_compile_item_view_spec.rb