Sha256: 6dce0ec3d5c3e0a29fbe865f922eecf435660a4d4e82339d5e7af867a40fe3dc

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require "test_helper"

module PushType
  describe Nestable do

    # Reset to default
    before(:all) { PushType.config.root_node_types = :all }

    let(:page) { TestPage.new }
    let(:roots) { PushType.root_node_types }

    describe '.has_child_nodes' do
      describe 'defaults' do
        before { TestPage.instance_variable_set '@child_node_types', nil }
        it { TestPage.child_node_types.must_equal roots }
        it { page.child_node_types.must_equal roots }
      end

      describe 'when none' do
        before { TestPage.has_child_nodes false }
        it { TestPage.child_node_types.must_equal [] }
        it { page.child_node_types.must_equal [] }
      end

      describe 'when all' do
        before { TestPage.has_child_nodes :all }
        it { TestPage.child_node_types.must_equal roots }
        it { page.child_node_types.must_equal roots }
      end

      describe 'when specific' do
        before { TestPage.has_child_nodes :page }
        it { TestPage.child_node_types.must_equal ['page'] }
        it { page.child_node_types.must_equal ['page'] }
      end

      describe 'when nonsense' do
        before { TestPage.has_child_nodes :foo, :bar }
        it { TestPage.child_node_types.must_equal [] }
        it { page.child_node_types.must_equal [] }
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
push_type_core-0.1.1 test/models/concerns/push_type/nestable_test.rb
push_type_core-0.1.0 test/models/concerns/push_type/nestable_test.rb