4 include Merb::Global::Providers
6 def self.providers_classes
10 def self.providers_classes=(providers_classes)
11 @@providers_classes = providers_classes
16 @@providers_classes = {}
20 describe Merb::Global::Providers do
26 it 'should lookup classes' do
28 provider_klass = mock do |klass|
29 klass.expects(:new).returns(provider)
31 TestProviders.providers_classes = {:test => provider_klass}
32 TestProviders[:test].should == provider
35 it 'should load the provider' do
37 provider_path = 'merb_global/test_providers/test'
38 TestProviders.expects(:require).with(provider_path)
39 class TestProviders::Test; end
40 TestProviders[provider] === TestProviders::Test
43 it 'should create the provider' do
45 TestProviders.stubs(:require)
46 class TestProviders::Test; end
47 TestProviders::Test.expects(:new)
48 TestProviders[provider] === TestProviders::Test
52 describe '.register' do
53 it 'should add the provider to hash' do
55 TestProviders.register(:test, provider_class)
56 TestProviders.providers_classes.should == {:test => provider_class}