spec/lib/radiant/initializer_spec.rb in radiant-0.8.2 vs spec/lib/radiant/initializer_spec.rb in radiant-0.9.0.rc2
- old
+ new
@@ -68,10 +68,34 @@
@configuration.extension('does_not_exist')
lambda {
@configuration.check_extension_dependencies
}.should raise_error(SystemExit)
end
+
+ describe "#all_available_extensions" do
+ before do
+ @spec = mock(Gem::Specification)
+ @gem = mock(Rails::GemDependency, :specification => @spec)
+ @configuration.gems = [@gem]
+ end
+
+ it "should not load gems that don't follow extension conventions" do
+ @spec.stub!(:full_gem_path).and_return(File.join(RADIANT_ROOT, %w(test fixtures gems misnamed_ext-0.0.0)))
+ available_extensions = @configuration.all_available_extensions.map(&:to_s)
+ available_extensions.grep(/misnamed_ext/).should be_empty
+ end
+
+ it "should skip gems with invalid specifications" do
+ @configuration.gems = [Rails::GemDependency.new('bogus_gem')]
+ @configuration.all_available_extensions.should_not include(:bogus_gem)
+ end
+
+ it "should load gems matching radiant-*-extension" do
+ @spec.stub!(:full_gem_path).and_return(File.join(RADIANT_ROOT, %w(test fixtures gems radiant-gem_ext-extension-0.0.0)))
+ @configuration.all_available_extensions.should include(:gem_ext)
+ end
+ end
end
describe Radiant::Initializer do
before :each do
@@ -108,24 +132,30 @@
@initializer.extension_loader.should_receive(:activate_extensions)
@initializer.after_initialize
end
it "should initialize admin tabs" do
+ Radiant::AdminUI.instance.should_receive(:load_default_nav)
@initializer.initialize_default_admin_tabs
- Radiant::AdminUI.instance.tabs.size.should == 3
end
it "should have access to the AdminUI" do
@initializer.admin.should == Radiant::AdminUI.instance
end
it "should load metal from RADIANT_ROOT and exensions" do
- Rails::Rack::Metal.metal_paths.should == ["#{RADIANT_ROOT}/app/metal", "#{RADIANT_ROOT}/test/fixtures/extensions/02_overriding/app/metal", "#{RADIANT_ROOT}/test/fixtures/extensions/01_basic/app/metal"]
+ Rails::Rack::Metal.metal_paths.should == ["#{RADIANT_ROOT}/app/metal", "#{RADIANT_ROOT}/test/fixtures/extensions/overriding/app/metal", "#{RADIANT_ROOT}/test/fixtures/extensions/basic/app/metal"]
end
it "should check dependent extensions" do
@initializer.configuration.frameworks = [] # ActionMailer not loaded at this point
@initializer.configuration.should_receive(:check_extension_dependencies)
@initializer.after_initialize
end
+ it "should remove extension gem paths from ActiveSupport::Dependencies" do
+ load_paths = [File.join(RADIANT_ROOT, %w(test fixtures gems radiant-gem_ext-extension-0.0.0 lib))]
+ @loader.stub!(:extension_load_paths).and_return(load_paths)
+ ActiveSupport::Dependencies.load_once_paths.should_receive(:-).with(load_paths)
+ @initializer.add_plugin_load_paths
+ end
end