Sha256: 40e8c7e7dad3675a8fda8e5b9e54092aa202ffae8ffbc6f212688611c8f0c1f2

Contents?: true

Size: 1.44 KB

Versions: 18

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

describe Nanoc::Spec::HelperContext do
  let(:helper) do
    Module.new {}
  end

  subject(:ctx) { described_class.new(helper) }

  it 'has no items by default' do
    # TODO: Add #empty? to item collection view
    expect(subject.items.size).to eq(0)
  end

  it 'has no layouts by default' do
    # TODO: Add #empty? to item collection view
    expect(subject.layouts.size).to eq(0)
  end

  describe '#create_item' do
    subject { ctx.create_item('foo', {}, '/foo.md') }

    it 'creates item' do
      expect { subject }
        .to change { ctx.items.size }
        .from(0).to(1)
    end

    it 'creates item without reps' do
      subject
      expect(ctx.items['/foo.md'].reps.size).to eq(0)
    end

    it 'returns self' do
      expect(subject).to eq(ctx)
    end
  end

  describe '#create_layout' do
    subject { ctx.create_layout('foo', {}, '/foo.md') }

    it 'creates layout' do
      expect { subject }
        .to change { ctx.layouts.size }
        .from(0).to(1)
    end

    it 'returns self' do
      expect(subject).to eq(ctx)
    end
  end

  describe '#create_rep' do
    before do
      ctx.create_item('foo', {}, '/foo.md')
    end

    subject { ctx.create_rep(ctx.items['/foo.md'], '/foo.html') }

    it 'creates rep' do
      expect { subject }
        .to change { ctx.items['/foo.md'].reps.size }
        .from(0).to(1)
    end

    it 'returns self' do
      expect(subject).to eq(ctx)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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