Sha256: 29c9c9f7fdd4517197279c5622585018288205c2e44114e24541daeb89f1314a

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'


module MockModuleToInclude
  def self.included(dsl)
  end
end

describe ActiveAdmin::DSL do

  let(:config){ double }
  let(:application) { ActiveAdmin::Application.new }
  let(:namespace) { ActiveAdmin::Namespace.new application, :admin }
  let(:resource_config) { ActiveAdmin::Resource.new namespace, Post }
  let(:dsl){ ActiveAdmin::DSL.new(config) }

  describe "#include" do

    it "should call the included class method on the module that is included" do
      expect(MockModuleToInclude).to receive(:included).with(dsl)
      dsl.run_registration_block do
        include MockModuleToInclude
      end
    end

  end

  describe "#menu" do

    it "should set the menu_item_options on the configuration" do
      expect(config).to receive(:menu_item_options=).with({parent: "Admin"})
      dsl.run_registration_block do
        menu parent: "Admin"
      end
    end

  end

  describe "#navigation_menu" do

    it "should set the navigation_menu_name on the configuration" do
      expect(config).to receive(:navigation_menu_name=).with(:admin)
      dsl.run_registration_block do
        navigation_menu :admin
      end
    end

    it "should accept a block" do

      dsl = ActiveAdmin::DSL.new(resource_config)
      dsl.run_registration_block do
        navigation_menu { :dynamic_menu }
      end

      expect(resource_config.navigation_menu_name).to eq :dynamic_menu

    end

  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
active_administration-0.0.3 spec/unit/dsl_spec.rb
activeadministration-0.0.2 spec/unit/dsl_spec.rb
active_administration-0.0.2 spec/unit/dsl_spec.rb
activeadministration-0.0.1 spec/unit/dsl_spec.rb
active_administration-0.0.1 spec/unit/dsl_spec.rb