Sha256: 4886fa8b2810b0831b7a578e87957b37b976c2c93048da9627d5f806af891159

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

describe Rails::Plugin::Loader do
  attr_reader :loader, :plugin, :directory

  before do
    @loader = Rails::Plugin::Loader.new(OpenStruct.new({ :loaded_plugins => [] }))
  end

  describe "#register_plugin_as_loaded" do
    before do
      paths = []
      stub(EngineAssets::PublicLocator).paths { paths }
    end

    context "given a plugin which is an engine and contains a 'public' directory" do
      before do
        @directory = File.join(basedir, 'spec', 'support', 'fixtures')
        @plugin    = OpenStruct.new({ :engine? => true, :directory => directory })
      end

      it "registers the plugin with the EngineAssets::PublicLocator" do
        loader.send(:register_plugin_as_loaded, plugin)
        EngineAssets::PublicLocator.paths.should == [ "#{directory}/public" ]
      end
    end

    context "given a plugin which is an engine and does NOT contain a 'public' directory" do
      before do
        @directory = basedir
        @plugin    = OpenStruct.new({ :engine? => true, :directory => directory })
      end

      it "does not register the plugin with the EngineAssets::PublicLocator" do
        loader.send(:register_plugin_as_loaded, plugin)
        EngineAssets::PublicLocator.paths.should == []
      end
    end

    context "given a plugin which is NOT an engine" do
      before do
        @directory = File.join(basedir, 'spec', 'support', 'fixtures')
        @plugin    = OpenStruct.new({ :engine? => false, :directory => directory })
      end

      it "does not register the plugin with the EngineAssets::PublicLocator" do
        loader.send(:register_plugin_as_loaded, plugin)
        EngineAssets::PublicLocator.paths.should == []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
engine-assets-0.3.0 spec/lib/engine_assets/extensions/rails/plugins_spec.rb