Sha256: c19dcd9049e0134d7d2b1d45e2a0d9122aa5e655c26a9448c520c75ec0bf3fb5

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

module Alchemy
  class ModulesTestController < ApplicationController
    include Modules
  end

  describe Modules do
    let(:controller)      { ModulesTestController.new }
    let(:alchemy_modules) { YAML.load_file(File.expand_path('../../../config/alchemy/modules.yml', __FILE__)) }

    describe '#module_definition_for' do
      subject { controller.module_definition_for(name) }

      let(:dashboard_module) { alchemy_modules.first }

      context 'with a string given as name' do
        let(:name) { 'dashboard' }

        it "returns the module definition" do
          should == dashboard_module
        end
      end

      context 'with a hash given as name' do
        let(:controller_name) { 'alchemy/admin/dashboard' }
        let(:name)            { {controller: controller_name, action: 'index'} }

        it "returns the module definition" do
          should == dashboard_module
        end

        context 'with leading slash in controller name' do
          let(:controller_name) { '/alchemy/admin/dashboard' }

          it "returns the module definition" do
            should == dashboard_module
          end
        end
      end

      context 'with nil given as name' do
        let(:name) { nil }
        it 'raises an error' do
          expect { subject }.to raise_error('Could not find module definition for ')
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
alchemy_cms-2.9.1 spec/libraries/modules_spec.rb
alchemy_cms-2.9.0 spec/libraries/modules_spec.rb
alchemy_cms-2.8.3 spec/libraries/modules_spec.rb
alchemy_cms-2.7.5 spec/libraries/modules_spec.rb
alchemy_cms-2.7.4 spec/libraries/modules_spec.rb
alchemy_cms-2.8.2 spec/libraries/modules_spec.rb
alchemy_cms-2.8.1 spec/libraries/modules_spec.rb
alchemy_cms-2.7.3 spec/libraries/modules_spec.rb
alchemy_cms-2.7.2 spec/libraries/modules_spec.rb
alchemy_cms-2.7.1 spec/libraries/modules_spec.rb